From commits-return-52829-archive-asf-public=cust-asf.ponee.io@activemq.apache.org Wed Aug 15 00:46:07 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id BF2A7180654 for ; Wed, 15 Aug 2018 00:46:06 +0200 (CEST) Received: (qmail 58569 invoked by uid 500); 14 Aug 2018 22:46:05 -0000 Mailing-List: contact commits-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list commits@activemq.apache.org Received: (qmail 58560 invoked by uid 99); 14 Aug 2018 22:46:05 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 14 Aug 2018 22:46:05 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id C2C30DFF66; Tue, 14 Aug 2018 22:46:05 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: michaelpearce@apache.org To: commits@activemq.apache.org Date: Tue, 14 Aug 2018 22:46:05 -0000 Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: [1/2] activemq-artemis git commit: ARTEMIS-2033 add spring-boot-integration example Repository: activemq-artemis Updated Branches: refs/heads/master 94e34febf -> dd15aa87d ARTEMIS-2033 add spring-boot-integration example Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/550c79b1 Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/550c79b1 Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/550c79b1 Branch: refs/heads/master Commit: 550c79b1341462f0cb4721018451abeee414d9dc Parents: 94e34fe Author: Ricardo Zanini Authored: Sun Aug 12 18:16:10 2018 -0300 Committer: Michael Andre Pearce Committed: Tue Aug 14 23:45:31 2018 +0100 ---------------------------------------------------------------------- examples/features/standard/pom.xml | 1 + .../standard/spring-boot-integration/README.md | 7 ++ .../standard/spring-boot-integration/pom.xml | 102 +++++++++++++++++++ .../jms/example/springboot/Application.java | 70 +++++++++++++ .../jms/example/springboot/ExampleListener.java | 29 ++++++ .../jms/example/springboot/MessageSender.java | 41 ++++++++ ...dditional-spring-configuration-metadata.json | 44 ++++++++ .../src/main/resources/application.properties | 23 +++++ .../src/main/resources/broker.xml | 42 ++++++++ .../src/main/resources/logback.xml | 38 +++++++ 10 files changed, 397 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/550c79b1/examples/features/standard/pom.xml ---------------------------------------------------------------------- diff --git a/examples/features/standard/pom.xml b/examples/features/standard/pom.xml index 0493457..6ede897 100644 --- a/examples/features/standard/pom.xml +++ b/examples/features/standard/pom.xml @@ -94,6 +94,7 @@ under the License. shared-consumer slow-consumer spring-integration + spring-boot-integration ssl-enabled ssl-enabled-crl-mqtt ssl-enabled-dual-authentication http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/550c79b1/examples/features/standard/spring-boot-integration/README.md ---------------------------------------------------------------------- diff --git a/examples/features/standard/spring-boot-integration/README.md b/examples/features/standard/spring-boot-integration/README.md new file mode 100644 index 0000000..075bbd0 --- /dev/null +++ b/examples/features/standard/spring-boot-integration/README.md @@ -0,0 +1,7 @@ +# ActiveMQ Artemis Spring Boot Example + +To run the example, simply type **mvn verify -Pexample** from this directory. + +This example shows how to setup and run an embedded broker within a Spring Boot Application relying on [AMQP 1.0 JMS Spring Boot project](https://github.com/amqphub/amqp-10-jms-spring-boot) for configuration. + + http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/550c79b1/examples/features/standard/spring-boot-integration/pom.xml ---------------------------------------------------------------------- diff --git a/examples/features/standard/spring-boot-integration/pom.xml b/examples/features/standard/spring-boot-integration/pom.xml new file mode 100644 index 0000000..10d4d76 --- /dev/null +++ b/examples/features/standard/spring-boot-integration/pom.xml @@ -0,0 +1,102 @@ + + + + 4.0.0 + + org.apache.activemq.examples.broker + jms-examples + 2.7.0-SNAPSHOT + + spring-boot-integration + ActiveMQ Artemis JMS Spring Boot Integration Example + + + ${project.basedir}/../../../.. + + + 2.0.1 + + + + + org.apache.activemq + artemis-amqp-protocol + ${project.version} + + + org.amqphub.spring + amqp-10-jms-spring-boot-starter + ${amqp-10-jms-spring.version} + + + + + + org.springframework.boot + spring-boot-maven-plugin + 2.0.4.RELEASE + + + + + + example + + + + org.apache.activemq + artemis-maven-plugin + + + runClient + + runClient + + + org.apache.activemq.artemis.jms.example.springboot.Application + + + + + + org.apache.activemq.examples.broker + spring-boot-integration + ${project.version} + + + + + org.apache.maven.plugins + maven-clean-plugin + + + + + + release + + + + com.vladsch.flexmark + markdown-page-generator-plugin + + + + + + \ No newline at end of file http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/550c79b1/examples/features/standard/spring-boot-integration/src/main/java/org/apache/activemq/artemis/jms/example/springboot/Application.java ---------------------------------------------------------------------- diff --git a/examples/features/standard/spring-boot-integration/src/main/java/org/apache/activemq/artemis/jms/example/springboot/Application.java b/examples/features/standard/spring-boot-integration/src/main/java/org/apache/activemq/artemis/jms/example/springboot/Application.java new file mode 100644 index 0000000..a42c6ce --- /dev/null +++ b/examples/features/standard/spring-boot-integration/src/main/java/org/apache/activemq/artemis/jms/example/springboot/Application.java @@ -0,0 +1,70 @@ +/* + * 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.activemq.artemis.jms.example.springboot; + +import org.apache.activemq.artemis.core.config.impl.SecurityConfiguration; +import org.apache.activemq.artemis.core.server.embedded.EmbeddedActiveMQ; +import org.apache.activemq.artemis.spi.core.security.ActiveMQJAASSecurityManager; +import org.apache.activemq.artemis.spi.core.security.jaas.InVMLoginModule; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.ConfigurableApplicationContext; +import org.springframework.context.annotation.Bean; +import org.springframework.jms.annotation.EnableJms; + +/** + * @see Spring JMS Messaging Guide + */ +@SpringBootApplication +@EnableJms +public class Application { + public Application() { + + } + + public static void main(String[] args) throws InterruptedException { + final ConfigurableApplicationContext context = SpringApplication.run(Application.class); + System.out.println("********************* Sending message..."); + MessageSender sender = context.getBean(MessageSender.class); + sender.send("Hello Artemis!"); + Thread.sleep(1000); + context.close(); + } + + @Bean + public ActiveMQJAASSecurityManager securityManager(@Value("${amq.broker.user}") String user, + @Value("${amq.broker.password}") String password, + @Value("${amq.broker.role}") String role) { + final SecurityConfiguration configuration = new SecurityConfiguration(); + final ActiveMQJAASSecurityManager securityManager = + new ActiveMQJAASSecurityManager(InVMLoginModule.class.getName(), configuration); + configuration.addUser(user, password); + configuration.addRole(user, role); + configuration.setDefaultUser(user); + + return securityManager; + } + + @Bean(initMethod = "start", destroyMethod = "stop") + public EmbeddedActiveMQ embeddedActiveMQ(ActiveMQJAASSecurityManager securityManager) { + final EmbeddedActiveMQ embeddedActiveMQ = new EmbeddedActiveMQ(); + embeddedActiveMQ.setSecurityManager(securityManager); + return embeddedActiveMQ; + } + +} http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/550c79b1/examples/features/standard/spring-boot-integration/src/main/java/org/apache/activemq/artemis/jms/example/springboot/ExampleListener.java ---------------------------------------------------------------------- diff --git a/examples/features/standard/spring-boot-integration/src/main/java/org/apache/activemq/artemis/jms/example/springboot/ExampleListener.java b/examples/features/standard/spring-boot-integration/src/main/java/org/apache/activemq/artemis/jms/example/springboot/ExampleListener.java new file mode 100644 index 0000000..82bdc3e --- /dev/null +++ b/examples/features/standard/spring-boot-integration/src/main/java/org/apache/activemq/artemis/jms/example/springboot/ExampleListener.java @@ -0,0 +1,29 @@ +/* + * 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.activemq.artemis.jms.example.springboot; + +import org.springframework.jms.annotation.JmsListener; +import org.springframework.stereotype.Component; + +@Component +public class ExampleListener { + + @JmsListener(destination = "${amq.queue}") + public void receiveMessage(String message) { + System.out.println("*********************** MESSAGE RECEIVED: " + message); + } +} http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/550c79b1/examples/features/standard/spring-boot-integration/src/main/java/org/apache/activemq/artemis/jms/example/springboot/MessageSender.java ---------------------------------------------------------------------- diff --git a/examples/features/standard/spring-boot-integration/src/main/java/org/apache/activemq/artemis/jms/example/springboot/MessageSender.java b/examples/features/standard/spring-boot-integration/src/main/java/org/apache/activemq/artemis/jms/example/springboot/MessageSender.java new file mode 100644 index 0000000..70f1124 --- /dev/null +++ b/examples/features/standard/spring-boot-integration/src/main/java/org/apache/activemq/artemis/jms/example/springboot/MessageSender.java @@ -0,0 +1,41 @@ +/* + * 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.activemq.artemis.jms.example.springboot; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.jms.core.JmsTemplate; +import org.springframework.stereotype.Component; + +@Component +public class MessageSender { + + @Autowired + private JmsTemplate jmsTemplate; + + @Value("${amq.queue}") + private String queue; + + public MessageSender() { + + } + + public void send(String message) { + jmsTemplate.convertAndSend(queue, message); + } + +} http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/550c79b1/examples/features/standard/spring-boot-integration/src/main/resources/META-INF/additional-spring-configuration-metadata.json ---------------------------------------------------------------------- diff --git a/examples/features/standard/spring-boot-integration/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/examples/features/standard/spring-boot-integration/src/main/resources/META-INF/additional-spring-configuration-metadata.json new file mode 100644 index 0000000..fbe5563 --- /dev/null +++ b/examples/features/standard/spring-boot-integration/src/main/resources/META-INF/additional-spring-configuration-metadata.json @@ -0,0 +1,44 @@ +/** + * 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. +*/ + +{"properties": [ + { + "name": "amq.queue", + "type": "java.lang.String", + "description": "A description for 'amq.queue'" + }, + { + "name": "amq.broker.password", + "type": "java.lang.String", + "description": "A description for 'amq.broker.password'" + }, + { + "name": "amq.broker.user", + "type": "java.lang.String", + "description": "A description for 'amq.broker.user'" + }, + { + "name": "amq.broker.user", + "type": "java.lang.String", + "description": "A description for 'amq.broker.user'" + }, + { + "name": "amq.broker.role", + "type": "java.lang.String", + "description": "A description for 'amq.broker.role'" + } +]} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/550c79b1/examples/features/standard/spring-boot-integration/src/main/resources/application.properties ---------------------------------------------------------------------- diff --git a/examples/features/standard/spring-boot-integration/src/main/resources/application.properties b/examples/features/standard/spring-boot-integration/src/main/resources/application.properties new file mode 100644 index 0000000..14f0c2e --- /dev/null +++ b/examples/features/standard/spring-boot-integration/src/main/resources/application.properties @@ -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. +## --------------------------------------------------------------------------- +amqphub.amqp10jms.remote-url=amqp://localhost:61616 +amqphub.amqp10jms.username=guest +amqphub.amqp10jms.password=guest +amq.broker.password=guest +amq.broker.user=guest +amq.broker.role=guest +amq.queue=exampleQueue \ No newline at end of file http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/550c79b1/examples/features/standard/spring-boot-integration/src/main/resources/broker.xml ---------------------------------------------------------------------- diff --git a/examples/features/standard/spring-boot-integration/src/main/resources/broker.xml b/examples/features/standard/spring-boot-integration/src/main/resources/broker.xml new file mode 100644 index 0000000..099363e --- /dev/null +++ b/examples/features/standard/spring-boot-integration/src/main/resources/broker.xml @@ -0,0 +1,42 @@ + + + + + + false + + + tcp://0.0.0.0:61616?protocols=AMQP,CORE + + + + + + + + + + + + + + + + http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/550c79b1/examples/features/standard/spring-boot-integration/src/main/resources/logback.xml ---------------------------------------------------------------------- diff --git a/examples/features/standard/spring-boot-integration/src/main/resources/logback.xml b/examples/features/standard/spring-boot-integration/src/main/resources/logback.xml new file mode 100644 index 0000000..2f867cd --- /dev/null +++ b/examples/features/standard/spring-boot-integration/src/main/resources/logback.xml @@ -0,0 +1,38 @@ + + + + + + + %d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n + + + + + + + + + + + + +