diff --git a/.github/workflows/plugins-test.yaml b/.github/workflows/plugins-test.yaml index b746617ec02ec3e3296303f5f51488db86f36e43..4d2590b0be2204145b9ca21db61e222040b6feb4 100644 --- a/.github/workflows/plugins-test.yaml +++ b/.github/workflows/plugins-test.yaml @@ -458,7 +458,7 @@ jobs: - name: Run elasticsearch-6.x-scenario 6.7.1-6.8.4 (7) run: bash test/plugin/run.sh elasticsearch-6.x-scenario - Oracle_Kafka_JdkHttp_JdkThreading: + Oracle_Activemq_Kafka_JdkHttp_JdkThreading: runs-on: ubuntu-18.04 timeout-minutes: 90 strategy: @@ -485,6 +485,8 @@ jobs: ./mvnw install:install-file -Dfile=ojdbc14-10.2.0.4.0.jar -DgroupId=com.oracle -DartifactId=ojdbc14 -Dversion=10.2.0.4.0 -Dpackaging=jar ./mvnw -f test/plugin/pom.xml clean package -DskipTests docker:build -DBUILD_NO=local >/dev/null bash test/plugin/run.sh oracle-scenario + - name: Run activemq 5.10.0-5.15.4 (22) + run: bash test/plugin/run.sh activemq-scenario - name: Run kafka 0.11.0.0-2.3.0 (16) run: bash test/plugin/run.sh kafka-scenario - name: Run jdk http (1) 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 794e5b3ba4ab77a8c6964f6e24eacb623b19a881..0169b32e822f98971002943615dcf798181759b2 100644 --- a/docs/en/setup/service-agent/java-agent/Supported-list.md +++ b/docs/en/setup/service-agent/java-agent/Supported-list.md @@ -44,7 +44,7 @@ * MQ * [RocketMQ](https://github.com/apache/rocketmq) 4.x * [Kafka](http://kafka.apache.org) 0.11.0.0 -> 1.0 - * [ActiveMQ](https://github.com/apache/activemq) 5.x + * [ActiveMQ](https://github.com/apache/activemq) 5.10.0 -> 5.15.4 * [RabbitMQ](https://www.rabbitmq.com/) 5.x * [Pulsar](http://pulsar.apache.org) 2.2.x -> 2.4.x * NoSQL diff --git a/test/plugin/scenarios/activemq-scenario/bin/startup.sh b/test/plugin/scenarios/activemq-scenario/bin/startup.sh new file mode 100644 index 0000000000000000000000000000000000000000..ea1553229d745d02fccdf881b23dc37abe3672e4 --- /dev/null +++ b/test/plugin/scenarios/activemq-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/activemq-scenario.jar & \ No newline at end of file diff --git a/test/plugin/scenarios/activemq-scenario/config/expectedData.yaml b/test/plugin/scenarios/activemq-scenario/config/expectedData.yaml new file mode 100644 index 0000000000000000000000000000000000000000..a987e05f2bdb1d8bd7441178d9ab123c9c7cb7ef --- /dev/null +++ b/test/plugin/scenarios/activemq-scenario/config/expectedData.yaml @@ -0,0 +1,81 @@ +# 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. +registryItems: + applications: + - {activemq-scenario: nq 0} + instances: + - {activemq-scenario: nq 0} + operationNames: + - activemq-scenario: [ActiveMQ/Queue/test/Consumer, /activemq-scenario/case/activemq] + heartbeat: [] +segmentItems: +- applicationCode: activemq-scenario + segmentSize: ge 2 + segments: + - segmentId: not null + spans: + - operationName: ActiveMQ/Queue/test/Producer + operationId: 0 + parentSpanId: 0 + spanId: 1 + spanLayer: MQ + startTime: nq 0 + endTime: nq 0 + componentId: 45 + componentName: '' + isError: false + spanType: Exit + peer: not null + peerId: 0 + tags: + - {key: mq.broker, value: not null} + - {key: mq.queue, value: test} + - operationName: /activemq-scenario/case/activemq + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: Http + startTime: nq 0 + endTime: nq 0 + componentId: 1 + componentName: '' + isError: false + spanType: Entry + peer: '' + peerId: 0 + tags: + - {key: url, value: 'http://localhost:8080/activemq-scenario/case/activemq'} + - {key: http.method, value: GET} + - segmentId: not null + spans: + - operationName: ActiveMQ/Queue/test/Consumer + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: MQ + startTime: nq 0 + endTime: nq 0 + componentId: 46 + componentName: '' + isError: false + spanType: Entry + peer: '' + peerId: 0 + tags: + - {key: mq.broker, value: not null} + - {key: mq.queue, value: test} + refs: + - {parentEndpointId: 0, parentEndpoint: /activemq-scenario/case/activemq, networkAddressId: 0, entryEndpointId: 0, refType: CrossProcess, parentSpanId: 1, parentTraceSegmentId: '${activemq-scenario[0]}', parentServiceInstanceId: nq 0, networkAddress: not null, entryEndpoint: /activemq-scenario/case/activemq, entryServiceInstanceId: nq 0} diff --git a/test/plugin/scenarios/activemq-scenario/configuration.yml b/test/plugin/scenarios/activemq-scenario/configuration.yml new file mode 100644 index 0000000000000000000000000000000000000000..bce707925a8f0e2c1343ba7ba768b4e6ce9a9182 --- /dev/null +++ b/test/plugin/scenarios/activemq-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/activemq-scenario/case/activemq +healthCheck: http://localhost:8080/activemq-scenario/case/healthCheck +startScript: ./bin/startup.sh +framework: activemq-scenario +environment: +- activemq.server=tcp://activemq-server:61616 +dependencies: + activemq-server: + image: rmohr/activemq:${CASE_SERVER_IMAGE_VERSION} + hostname: activemq-server + expose: + - 8161 + - 61616 diff --git a/test/plugin/scenarios/activemq-scenario/pom.xml b/test/plugin/scenarios/activemq-scenario/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..9addfa4fe3e9c81c103a0474568edf0542269b71 --- /dev/null +++ b/test/plugin/scenarios/activemq-scenario/pom.xml @@ -0,0 +1,118 @@ + + + + + org.apache.skywalking.apm.testcase + activemq-scenario + 1.0.0 + jar + + 4.0.0 + + + UTF-8 + 1.8 + + 5.14.5 + + 2.1.6.RELEASE + + + skywalking-activemq-scenario + + + + + org.springframework.boot + spring-boot-dependencies + ${spring-boot-version} + pom + import + + + + + + + org.apache.activemq + activemq-client + ${test.framework.version} + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-logging + + + + + org.springframework.boot + spring-boot-starter-log4j2 + + + + + activemq-scenario + + + org.springframework.boot + spring-boot-maven-plugin + + + + repackage + + + + + + maven-compiler-plugin + + ${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/activemq-scenario/src/main/assembly/assembly.xml b/test/plugin/scenarios/activemq-scenario/src/main/assembly/assembly.xml new file mode 100644 index 0000000000000000000000000000000000000000..a69dea3ddf070895080e9f98909126b113b04720 --- /dev/null +++ b/test/plugin/scenarios/activemq-scenario/src/main/assembly/assembly.xml @@ -0,0 +1,41 @@ + + + + + zip + + + + + ./bin + 0775 + + + + + + ${project.build.directory}/activemq-scenario.jar + ./libs + 0775 + + + diff --git a/test/plugin/scenarios/activemq-scenario/src/main/java/org/apache/skywalking/apm/testcase/activemq/Application.java b/test/plugin/scenarios/activemq-scenario/src/main/java/org/apache/skywalking/apm/testcase/activemq/Application.java new file mode 100644 index 0000000000000000000000000000000000000000..34dd60c55be468d0104f82463c93c9c1ace713b9 --- /dev/null +++ b/test/plugin/scenarios/activemq-scenario/src/main/java/org/apache/skywalking/apm/testcase/activemq/Application.java @@ -0,0 +1,35 @@ +/* + * 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.activemq; + +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/activemq-scenario/src/main/java/org/apache/skywalking/apm/testcase/activemq/controller/CaseController.java b/test/plugin/scenarios/activemq-scenario/src/main/java/org/apache/skywalking/apm/testcase/activemq/controller/CaseController.java new file mode 100644 index 0000000000000000000000000000000000000000..306beba9a931c12262c346cc0a3fb49f11fcac22 --- /dev/null +++ b/test/plugin/scenarios/activemq-scenario/src/main/java/org/apache/skywalking/apm/testcase/activemq/controller/CaseController.java @@ -0,0 +1,132 @@ +/* + * 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.activemq.controller; + +import javax.jms.Connection; +import javax.jms.ConnectionFactory; +import javax.jms.Destination; +import javax.jms.JMSException; +import javax.jms.MessageConsumer; +import javax.jms.MessageProducer; +import javax.jms.Session; +import javax.jms.TextMessage; +import org.apache.activemq.ActiveMQConnection; +import org.apache.activemq.ActiveMQConnectionFactory; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; + +@RestController +@RequestMapping("/case") +public class CaseController { + + private static final Logger logger = LogManager.getLogger(CaseController.class); + + @Value("${activemq.server}") + private String brokenUrl; + + private static final String USER_NAME = ActiveMQConnection.DEFAULT_USER; + private static final String PASSWORD = ActiveMQConnection.DEFAULT_PASSWORD; + + private static final String SUCCESS = "Success"; + private static final String FAIL = "Fail"; + + @RequestMapping("/activemq") + @ResponseBody + public String testcase() { + Session session = null; + Connection connection = null; + try{ + ConnectionFactory factory = new ActiveMQConnectionFactory(USER_NAME, PASSWORD, brokenUrl); + connection = factory.createConnection(); + connection.start(); + session = connection.createSession(Boolean.TRUE, Session.AUTO_ACKNOWLEDGE); + Destination destination = session.createQueue("test"); + MessageProducer messageProducer = session.createProducer(destination); + TextMessage message = session.createTextMessage("test"); + messageProducer.send(message); + session.commit(); + session.close(); + connection.close(); + }catch (Exception ex){ + logger.error(ex); + try { + session.close(); + connection.close(); + } catch (JMSException e) { + logger.error(e); + } + } + new ConsumerThread().start(); + return SUCCESS; + } + + @RequestMapping("/healthCheck") + @ResponseBody + public String healthCheck() { + Session session = null; + Connection connection = null; + try { + ConnectionFactory factory = new ActiveMQConnectionFactory(USER_NAME, PASSWORD, brokenUrl); + connection = factory.createConnection(); + connection.start(); + connection.getMetaData().getJMSVersion(); + connection.close(); + }catch (Exception ex){ + logger.error(ex); + try { + session.close(); + connection.close(); + } catch (JMSException e) { + logger.error(e); + } + return FAIL; + } + return SUCCESS; + } + + public class ConsumerThread extends Thread { + @Override public void run() { + Session session = null; + Connection connection = null; + try{ + ConnectionFactory factory = new ActiveMQConnectionFactory(USER_NAME, PASSWORD, brokenUrl); + connection = factory.createConnection(); + connection.start(); + session = connection.createSession(Boolean.TRUE, Session.AUTO_ACKNOWLEDGE); + Destination destination = session.createQueue("test"); + MessageConsumer messageConsumer = session.createConsumer(destination); + messageConsumer.receive(); + session.close(); + connection.close(); + }catch (Exception ex){ + logger.error(ex); + try { + session.close(); + connection.close(); + } catch (JMSException e) { + logger.error(e); + } + } + } + } +} diff --git a/test/plugin/scenarios/activemq-scenario/src/main/resources/application.yaml b/test/plugin/scenarios/activemq-scenario/src/main/resources/application.yaml new file mode 100644 index 0000000000000000000000000000000000000000..ec85068fb45e2aab862026ea0e63d4377275f918 --- /dev/null +++ b/test/plugin/scenarios/activemq-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: /activemq-scenario +logging: + config: classpath:log4j2.xml \ No newline at end of file diff --git a/test/plugin/scenarios/activemq-scenario/src/main/resources/log4j2.xml b/test/plugin/scenarios/activemq-scenario/src/main/resources/log4j2.xml new file mode 100644 index 0000000000000000000000000000000000000000..9849ed5a8abd116a9000e64cc18f05e583f21c98 --- /dev/null +++ b/test/plugin/scenarios/activemq-scenario/src/main/resources/log4j2.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/plugin/scenarios/activemq-scenario/support-version.list b/test/plugin/scenarios/activemq-scenario/support-version.list new file mode 100644 index 0000000000000000000000000000000000000000..0602683f293383444769e818512ee60cfde84263 --- /dev/null +++ b/test/plugin/scenarios/activemq-scenario/support-version.list @@ -0,0 +1,38 @@ +# 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 +# "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. + +5.10.0 +5.10.1 +5.10.2 +5.11.0 +5.11.1 +5.12.0 +5.12.1 +5.12.2 +5.13.0 +5.13.1 +5.13.2 +5.13.3 +5.13.4 +5.14.0 +5.14.1 +5.14.2 +5.14.3 +5.14.4 +5.14.5 +5.15.2 +5.15.3 +5.15.4