diff --git a/spring-amqp/pom.xml b/spring-amqp/pom.xml new file mode 100755 index 0000000000..bb26b2d15d --- /dev/null +++ b/spring-amqp/pom.xml @@ -0,0 +1,41 @@ + + 4.0.0 + + com.baeldung + springamqp + 0.1-SNAPSHOT + jar + + springamqp + Introduction to Spring-AMQP + + + UTF-8 + 3.6.0 + + + + + org.springframework.amqp + spring-rabbit + 1.6.6.RELEASE + + + + + springamqp + + + org.apache.maven.plugins + maven-compiler-plugin + ${maven-compiler-plugin.version} + + 1.8 + 1.8 + true + + + + + diff --git a/spring-amqp/src/main/java/com/baeldung/springamqp/consumer/Consumer.java b/spring-amqp/src/main/java/com/baeldung/springamqp/consumer/Consumer.java new file mode 100644 index 0000000000..42d7e88cbd --- /dev/null +++ b/spring-amqp/src/main/java/com/baeldung/springamqp/consumer/Consumer.java @@ -0,0 +1,7 @@ +package com.baeldung.springamqp.consumer; + +public class Consumer { + public void listen(String foo) { + System.out.println(foo); + } +} \ No newline at end of file diff --git a/spring-amqp/src/main/java/com/baeldung/springamqp/producer/Producer.java b/spring-amqp/src/main/java/com/baeldung/springamqp/producer/Producer.java new file mode 100644 index 0000000000..b4067ed795 --- /dev/null +++ b/spring-amqp/src/main/java/com/baeldung/springamqp/producer/Producer.java @@ -0,0 +1,17 @@ +package com.baeldung.springamqp.producer; + +import org.springframework.amqp.core.AmqpTemplate; +import org.springframework.amqp.rabbit.core.RabbitTemplate; +import org.springframework.context.support.AbstractApplicationContext; +import org.springframework.context.support.ClassPathXmlApplicationContext; + +public class Producer { + + public static void main(String[] args) throws InterruptedException { + AbstractApplicationContext ctx = new ClassPathXmlApplicationContext("beans.xml"); + AmqpTemplate template = ctx.getBean(RabbitTemplate.class); + template.convertAndSend("Hello, world!"); + Thread.sleep(1000); + ctx.destroy(); + } +} \ No newline at end of file diff --git a/spring-amqp/src/main/resources/beans.xml b/spring-amqp/src/main/resources/beans.xml new file mode 100644 index 0000000000..f6a966b0f6 --- /dev/null +++ b/spring-amqp/src/main/resources/beans.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file