diff --git a/.github/workflows/plugins-test.3.yaml b/.github/workflows/plugins-test.3.yaml index 5960da690a..7065a3a0e8 100644 --- a/.github/workflows/plugins-test.3.yaml +++ b/.github/workflows/plugins-test.3.yaml @@ -108,6 +108,7 @@ jobs: - shenyu-2.4.x-grpc-scenario - shenyu-2.4.x-sofarpc-scenario - solon-2.x-scenario + - spring-jms-5.x-scenario steps: - uses: actions/checkout@v2 with: diff --git a/CHANGES.md b/CHANGES.md index 623b5015f1..5a04e0b1b7 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -22,7 +22,7 @@ Release Notes. * Improve 4x performance of ContextManagerExtendService.createTraceContext() * Add a plugin that supports the Solon framework. * Fixed issues in the MySQL component where the executeBatch method could result in empty SQL statements . - +* Add a plugin that supports the spring jms 5.x. All issues and pull requests are [here](https://github.com/apache/skywalking/milestone/213?closed=1) diff --git a/apm-sniffer/apm-sdk-plugin/spring-plugins/pom.xml b/apm-sniffer/apm-sdk-plugin/spring-plugins/pom.xml index 64abfdb7eb..c089d4a5ef 100644 --- a/apm-sniffer/apm-sdk-plugin/spring-plugins/pom.xml +++ b/apm-sniffer/apm-sdk-plugin/spring-plugins/pom.xml @@ -45,6 +45,7 @@ spring-webflux-5.x-webclient-plugin spring-webflux-6.x-webclient-plugin resttemplate-commons + spring-jms-5.x-plugin pom diff --git a/apm-sniffer/apm-sdk-plugin/spring-plugins/spring-jms-5.x-plugin/pom.xml b/apm-sniffer/apm-sdk-plugin/spring-plugins/spring-jms-5.x-plugin/pom.xml new file mode 100644 index 0000000000..85e949cc5c --- /dev/null +++ b/apm-sniffer/apm-sdk-plugin/spring-plugins/spring-jms-5.x-plugin/pom.xml @@ -0,0 +1,42 @@ + + + + 4.0.0 + + + org.apache.skywalking + spring-plugins + 9.3.0-SNAPSHOT + + + apm-spring-jms-5.x-plugin + + + 1.1.1 + + + + + org.apache.geronimo.specs + geronimo-jms_1.1_spec + ${geronimo-jms.version} + provided + + + \ No newline at end of file diff --git a/apm-sniffer/apm-sdk-plugin/spring-plugins/spring-jms-5.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/jms/MessageListenerInterceptor.java b/apm-sniffer/apm-sdk-plugin/spring-plugins/spring-jms-5.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/jms/MessageListenerInterceptor.java new file mode 100644 index 0000000000..deb6c4e7fe --- /dev/null +++ b/apm-sniffer/apm-sdk-plugin/spring-plugins/spring-jms-5.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/jms/MessageListenerInterceptor.java @@ -0,0 +1,76 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.skywalking.apm.plugin.spring.jms; + +import org.apache.skywalking.apm.agent.core.context.CarrierItem; +import org.apache.skywalking.apm.agent.core.context.ContextCarrier; +import org.apache.skywalking.apm.agent.core.context.ContextManager; +import org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult; +import org.apache.skywalking.apm.network.trace.component.ComponentsDefine; + +import javax.jms.Message; +import java.lang.reflect.Method; + +public class MessageListenerInterceptor implements InstanceMethodsAroundInterceptor { + + private static final String OPERATION_NAME_PREFIX = "Jms/"; + private static final String OPERATION_NAME_SUFFIX = "/Execute"; + + @Override + public void beforeMethod(EnhancedInstance objInst, + Method method, + Object[] allArguments, Class[] argumentsTypes, + MethodInterceptResult result) throws Throwable { + Message message = (Message) allArguments[1]; + ContextCarrier contextCarrier = new ContextCarrier(); + CarrierItem next = contextCarrier.items(); + while (next.hasNext()) { + next = next.next(); + Object propertyValue = message.getStringProperty(next.getHeadKey()); + if (propertyValue != null) { + next.setHeadValue(propertyValue.toString()); + } + } + AbstractSpan activeSpan = ContextManager.createEntrySpan(OPERATION_NAME_PREFIX + message.getJMSDestination() + OPERATION_NAME_SUFFIX, null); + activeSpan.setComponent(ComponentsDefine.SPRING_ASYNC); + ContextManager.extract(contextCarrier); + } + + @Override + public Object afterMethod(EnhancedInstance objInst, + Method method, + Object[] allArguments, + Class[] argumentsTypes, + Object ret) throws Throwable { + ContextManager.stopSpan(); + return ret; + } + + @Override + public void handleMethodException(EnhancedInstance objInst, + Method method, + Object[] allArguments, + Class[] argumentsTypes, + Throwable t) { + ContextManager.activeSpan().log(t); + } +} diff --git a/apm-sniffer/apm-sdk-plugin/spring-plugins/spring-jms-5.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/jms/define/MessageListenerInstrumentation.java b/apm-sniffer/apm-sdk-plugin/spring-plugins/spring-jms-5.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/jms/define/MessageListenerInstrumentation.java new file mode 100644 index 0000000000..b8dfd3609b --- /dev/null +++ b/apm-sniffer/apm-sdk-plugin/spring-plugins/spring-jms-5.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/jms/define/MessageListenerInstrumentation.java @@ -0,0 +1,68 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.skywalking.apm.plugin.spring.jms.define; + +import net.bytebuddy.description.method.MethodDescription; +import net.bytebuddy.matcher.ElementMatcher; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine; +import org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch; +import org.apache.skywalking.apm.agent.core.plugin.match.MultiClassNameMatch; + +import static net.bytebuddy.matcher.ElementMatchers.named; + +public class MessageListenerInstrumentation extends ClassInstanceMethodsEnhancePluginDefine { + + private static final String INTERCEPTOR_CLASS = "org.apache.skywalking.apm.plugin.spring.jms.MessageListenerInterceptor"; + public static final String ENHANCE_CLASS = "org.springframework.jms.listener.AbstractMessageListenerContainer"; + public static final String ENHANCE_METHOD = "doExecuteListener"; + + @Override + public ConstructorInterceptPoint[] getConstructorsInterceptPoints() { + return new ConstructorInterceptPoint[0]; + } + + @Override + public InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() { + return new InstanceMethodsInterceptPoint[] { + new InstanceMethodsInterceptPoint() { + @Override + public ElementMatcher getMethodsMatcher() { + return named(ENHANCE_METHOD); + } + + @Override + public String getMethodsInterceptor() { + return INTERCEPTOR_CLASS; + } + + @Override + public boolean isOverrideArgs() { + return false; + } + } + }; + } + + @Override + protected ClassMatch enhanceClass() { + return MultiClassNameMatch.byMultiClassMatch(ENHANCE_CLASS); + } +} diff --git a/apm-sniffer/apm-sdk-plugin/spring-plugins/spring-jms-5.x-plugin/src/main/resources/skywalking-plugin.def b/apm-sniffer/apm-sdk-plugin/spring-plugins/spring-jms-5.x-plugin/src/main/resources/skywalking-plugin.def new file mode 100644 index 0000000000..5672b8eb77 --- /dev/null +++ b/apm-sniffer/apm-sdk-plugin/spring-plugins/spring-jms-5.x-plugin/src/main/resources/skywalking-plugin.def @@ -0,0 +1,16 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +spring-jms-5.x=org.apache.skywalking.apm.plugin.spring.jms.define.MessageListenerInstrumentation diff --git a/docs/en/setup/service-agent/java-agent/Plugin-list.md b/docs/en/setup/service-agent/java-agent/Plugin-list.md index e15b3b1f00..83ae823688 100644 --- a/docs/en/setup/service-agent/java-agent/Plugin-list.md +++ b/docs/en/setup/service-agent/java-agent/Plugin-list.md @@ -177,4 +177,5 @@ - spring-webflux-6.x-webclient - activemq-artemis-jakarta-client-2.x - c3p0-0.9.x -- solon-2.x \ No newline at end of file +- solon-2.x +- spring-jms-5.x \ No newline at end of file diff --git a/docs/en/setup/service-agent/java-agent/Supported-list.md b/docs/en/setup/service-agent/java-agent/Supported-list.md index c91c25d4a2..b21c8709b1 100644 --- a/docs/en/setup/service-agent/java-agent/Supported-list.md +++ b/docs/en/setup/service-agent/java-agent/Supported-list.md @@ -84,6 +84,7 @@ metrics based on the tracing data. * [NATS](https://github.com/nats-io/nats.java) 2.14.x -> 2.15.x * [ActiveMQ-Artemis](https://github.com/apache/activemq) 2.30.0 -> 2.31.2 * Aliyun ONS 1.x (Optional¹) + * Spring Jms 5.x * NoSQL * [aerospike](https://github.com/aerospike/aerospike-client-java) 3.x -> 6.x * Redis diff --git a/test/plugin/scenarios/spring-jms-5.x-scenario/bin/startup.sh b/test/plugin/scenarios/spring-jms-5.x-scenario/bin/startup.sh new file mode 100644 index 0000000000..4c83688bbd --- /dev/null +++ b/test/plugin/scenarios/spring-jms-5.x-scenario/bin/startup.sh @@ -0,0 +1,21 @@ +#!/bin/bash +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +home="$(cd "$(dirname $0)"; pwd)" + +java -jar ${agent_opts} ${home}/../libs/spring-jms-5.x-scenario.jar & \ No newline at end of file diff --git a/test/plugin/scenarios/spring-jms-5.x-scenario/config/expectedData.yaml b/test/plugin/scenarios/spring-jms-5.x-scenario/config/expectedData.yaml new file mode 100644 index 0000000000..ceecdfb29f --- /dev/null +++ b/test/plugin/scenarios/spring-jms-5.x-scenario/config/expectedData.yaml @@ -0,0 +1,90 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +segmentItems: + - serviceName: spring-jms-5.x-scenario + segmentSize: ge 2 + segments: + - segmentId: not null + spans: + - operationName: ActiveMQ/Queue/test/Producer + parentSpanId: 0 + spanId: 1 + spanLayer: MQ + startTime: nq 0 + endTime: nq 0 + componentId: 45 + isError: false + spanType: Exit + peer: not blank + tags: + - { key: mq.broker, value: not blank } + - { key: mq.queue, value: test } + skipAnalysis: 'false' + - operationName: GET:/spring-jms-5.x-scenario/case/spring-jms-scenario + parentSpanId: -1 + spanId: 0 + spanLayer: Http + startTime: nq 0 + endTime: nq 0 + componentId: 1 + isError: false + spanType: Entry + peer: '' + tags: + - { key: url, value: 'http://localhost:8080/spring-jms-5.x-scenario/case/spring-jms-scenario' } + - { key: http.method, value: GET } + - { key: http.status_code, value: '200' } + skipAnalysis: 'false' + - segmentId: not null + spans: + - operationName: ActiveMQ/Queue/test/Consumer + parentSpanId: -1 + spanId: 0 + spanLayer: MQ + startTime: nq 0 + endTime: nq 0 + componentId: 46 + isError: false + spanType: Entry + peer: not blank + tags: + - { key: mq.broker, value: not blank } + - { key: mq.queue, value: test } + - { key: transmission.latency, value: ge 0 } + refs: + - { parentEndpoint: GET:/spring-jms-5.x-scenario/case/spring-jms-scenario, networkAddress: not null, + refType: CrossProcess, parentSpanId: 1, parentTraceSegmentId: not null, + parentServiceInstance: not null, parentService: not null, traceId: not null } + skipAnalysis: 'false' + - segmentId: not null + spans: + - operationName: Jms/queue://test/Execute + parentSpanId: -1 + spanId: 0 + spanLayer: Unknown + startTime: nq 0 + endTime: nq 0 + componentId: 65 + isError: false + spanType: Entry + peer: '' + tags: + - { key: transmission.latency, value: ge 0 } + refs: + - { parentEndpoint: GET:/spring-jms-5.x-scenario/case/spring-jms-scenario, networkAddress: not null, + refType: CrossProcess, parentSpanId: 1, parentTraceSegmentId: not null, + parentServiceInstance: not null, parentService: not null, traceId: not null } + skipAnalysis: 'false' diff --git a/test/plugin/scenarios/spring-jms-5.x-scenario/configuration.yml b/test/plugin/scenarios/spring-jms-5.x-scenario/configuration.yml new file mode 100644 index 0000000000..f19d35f3e9 --- /dev/null +++ b/test/plugin/scenarios/spring-jms-5.x-scenario/configuration.yml @@ -0,0 +1,30 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +type: jvm +entryService: http://localhost:8080/spring-jms-5.x-scenario/case/spring-jms-scenario +healthCheck: http://localhost:8080/spring-jms-5.x-scenario/case/healthCheck +withPlugins: apm-activemq-5.x-plugin-*.jar +startScript: ./bin/startup.sh +environment: + - activemq.server=tcp://activemq-server:61616 +dependencies: + activemq-server: + image: rmohr/activemq:5.14.5 + hostname: activemq-server + expose: + - 8161 + - 61616 \ No newline at end of file diff --git a/test/plugin/scenarios/spring-jms-5.x-scenario/pom.xml b/test/plugin/scenarios/spring-jms-5.x-scenario/pom.xml new file mode 100644 index 0000000000..b7214ee831 --- /dev/null +++ b/test/plugin/scenarios/spring-jms-5.x-scenario/pom.xml @@ -0,0 +1,128 @@ + + + + + org.apache.skywalking.apm.testcase + spring-jms-5.x-scenario + 1.0.0 + jar + + 4.0.0 + + + UTF-8 + 1.8 + 3.8.1 + 5.3.37 + 2.1.6.RELEASE + 1.18.20 + + + skywalking-spring-jms-5.x-scenario + + + + org.springframework.boot + spring-boot-starter-web + ${spring.boot.version} + + + org.springframework.boot + spring-boot-starter-logging + + + + + org.springframework.boot + spring-boot-starter-log4j2 + ${spring.boot.version} + + + org.projectlombok + lombok + ${lombok.version} + provided + + + org.springframework.boot + spring-boot-starter-activemq + ${spring.boot.version} + + + org.springframework + spring-jms + + + + + org.springframework + spring-jms + ${test.framework.version} + + + + + + spring-jms-5.x-scenario + + + org.springframework.boot + spring-boot-maven-plugin + ${spring.boot.version} + + + + repackage + + + + + + maven-compiler-plugin + ${maven-compiler-plugin.version} + + ${compiler.version} + ${compiler.version} + ${project.build.sourceEncoding} + + + + org.apache.maven.plugins + maven-assembly-plugin + + + assemble + package + + single + + + + src/main/assembly/assembly.xml + + ./target/ + + + + + + + diff --git a/test/plugin/scenarios/spring-jms-5.x-scenario/src/main/assembly/assembly.xml b/test/plugin/scenarios/spring-jms-5.x-scenario/src/main/assembly/assembly.xml new file mode 100644 index 0000000000..104b14a9ac --- /dev/null +++ b/test/plugin/scenarios/spring-jms-5.x-scenario/src/main/assembly/assembly.xml @@ -0,0 +1,41 @@ + + + + + zip + + + + + ./bin + 0775 + + + + + + ${project.build.directory}/spring-jms-5.x-scenario.jar + ./libs + 0775 + + + diff --git a/test/plugin/scenarios/spring-jms-5.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/spring/jms/Application.java b/test/plugin/scenarios/spring-jms-5.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/spring/jms/Application.java new file mode 100644 index 0000000000..58b72178a9 --- /dev/null +++ b/test/plugin/scenarios/spring-jms-5.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/spring/jms/Application.java @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.skywalking.apm.testcase.spring.jms; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class Application { + + public static void main(String[] args) { + try { + SpringApplication.run(Application.class, args); + } catch (Exception e) { + // Never do this + } + } +} diff --git a/test/plugin/scenarios/spring-jms-5.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/spring/jms/config/JmsConfig.java b/test/plugin/scenarios/spring-jms-5.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/spring/jms/config/JmsConfig.java new file mode 100644 index 0000000000..0abd37673e --- /dev/null +++ b/test/plugin/scenarios/spring-jms-5.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/spring/jms/config/JmsConfig.java @@ -0,0 +1,51 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.skywalking.apm.testcase.spring.jms.config; + +import org.apache.activemq.ActiveMQConnection; +import org.apache.activemq.ActiveMQConnectionFactory; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.jms.annotation.EnableJms; +import org.springframework.jms.config.DefaultJmsListenerContainerFactory; +import org.springframework.jms.config.JmsListenerContainerFactory; + +import javax.jms.ConnectionFactory; + +@Configuration +@EnableJms +public class JmsConfig { + @Value("${activemq.server}") + private String brokenUrl; + private static final String USER_NAME = ActiveMQConnection.DEFAULT_USER; + private static final String PASSWORD = ActiveMQConnection.DEFAULT_PASSWORD; + + @Bean + public ConnectionFactory connectionFactory() { + return new ActiveMQConnectionFactory(USER_NAME, PASSWORD, brokenUrl); + } + + @Bean + public JmsListenerContainerFactory jmsListenerContainerFactory(ConnectionFactory connectionFactory) { + DefaultJmsListenerContainerFactory bean = new DefaultJmsListenerContainerFactory(); + bean.setPubSubDomain(false); + bean.setConnectionFactory(connectionFactory); + return bean; + } +} diff --git a/test/plugin/scenarios/spring-jms-5.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/spring/jms/controller/CaseController.java b/test/plugin/scenarios/spring-jms-5.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/spring/jms/controller/CaseController.java new file mode 100644 index 0000000000..196a752a06 --- /dev/null +++ b/test/plugin/scenarios/spring-jms-5.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/spring/jms/controller/CaseController.java @@ -0,0 +1,61 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.skywalking.apm.testcase.spring.jms.controller; + +import lombok.extern.log4j.Log4j2; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.jms.annotation.JmsListener; +import org.springframework.jms.core.JmsMessagingTemplate; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.RestController; + +import javax.jms.Message; +import javax.jms.TextMessage; + +@RestController +@RequestMapping("/case") +@Log4j2 +public class CaseController { + + private static final String SUCCESS = "Success"; + + @Autowired + private JmsMessagingTemplate jmsMessagingTemplate; + + @RequestMapping("/spring-jms-scenario") + @ResponseBody + public String testcase() { + jmsMessagingTemplate.convertAndSend("test", "hello world"); + return SUCCESS; + } + + @RequestMapping("/healthCheck") + @ResponseBody + public String healthCheck() { + return SUCCESS; + } + + @JmsListener(destination = "test", concurrency = "10") + public void onMessageReceived(Message message) throws Exception { + TextMessage textMessage = (TextMessage) message; + log.info("received normal message: " + textMessage.getText()); + } + +} diff --git a/test/plugin/scenarios/spring-jms-5.x-scenario/src/main/resources/application.yaml b/test/plugin/scenarios/spring-jms-5.x-scenario/src/main/resources/application.yaml new file mode 100644 index 0000000000..189166b6a0 --- /dev/null +++ b/test/plugin/scenarios/spring-jms-5.x-scenario/src/main/resources/application.yaml @@ -0,0 +1,23 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# +server: + port: 8080 + servlet: + context-path: /spring-jms-5.x-scenario +logging: + config: classpath:log4j2.xml \ No newline at end of file diff --git a/test/plugin/scenarios/spring-jms-5.x-scenario/src/main/resources/log4j2.xml b/test/plugin/scenarios/spring-jms-5.x-scenario/src/main/resources/log4j2.xml new file mode 100644 index 0000000000..9849ed5a8a --- /dev/null +++ b/test/plugin/scenarios/spring-jms-5.x-scenario/src/main/resources/log4j2.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/plugin/scenarios/spring-jms-5.x-scenario/support-version.list b/test/plugin/scenarios/spring-jms-5.x-scenario/support-version.list new file mode 100644 index 0000000000..02e6b2f141 --- /dev/null +++ b/test/plugin/scenarios/spring-jms-5.x-scenario/support-version.list @@ -0,0 +1,18 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# lists your version here (Contains only the last version number of each minor version.) +5.3.37 \ No newline at end of file