Package org.springframework.amqp.core

Examples of org.springframework.amqp.core.AmqpTemplate


public class Consumer {
 
  public static void main(String[] args) {
    ApplicationContext context = new AnnotationConfigApplicationContext(HelloWorldConfiguration.class);
    AmqpTemplate amqpTemplate = context.getBean(AmqpTemplate.class);
    System.out.println("Received: " + amqpTemplate.receiveAndConvert());
  }
View Full Code Here


public class Producer {

  public static void main(String[] args) {
    ApplicationContext context = new AnnotationConfigApplicationContext(HelloWorldConfiguration.class);
    AmqpTemplate amqpTemplate = context.getBean(AmqpTemplate.class);
    amqpTemplate.convertAndSend("Hello World");
    System.out.println("Sent: Hello World");
  }
View Full Code Here

public class RabbitDemo {

  public static void main(String[] args) {
    ApplicationContext context = new ClassPathXmlApplicationContext("amqp/config.xml");
    AmqpTemplate template = context.getBean(AmqpTemplate.class);
    template.convertAndSend("samples.queue", "Hello AMQP");
  }
View Full Code Here

    private static final String[] BEAN_CONFIG = { "classpath:/META-INF/spring/jobs/messaging/rabbitmq-beans.xml",
            "classpath:/META-INF/spring/config-beans.xml" };

    public static void main(String[] args) {
        ApplicationContext applicationContext = new ClassPathXmlApplicationContext(BEAN_CONFIG);
        AmqpTemplate amqpTemplate = applicationContext.getBean("inboundAmqpTemplate", RabbitTemplate.class);

        for (int i = 0; i < SEND_MESSAGE_COUNT; i++ ) {
            amqpTemplate.convertAndSend("foo message: " + i);
        }

        ((ConfigurableApplicationContext) applicationContext).close();
    }
View Full Code Here

        new AmqpItemReader<String>(null);
    }

    @Test
    public void testNoItemType() {
        final AmqpTemplate amqpTemplate = mock(AmqpTemplate.class);
        when(amqpTemplate.receiveAndConvert()).thenReturn("foo");

        final AmqpItemReader<String> amqpItemReader = new AmqpItemReader<String>(amqpTemplate);
        assertEquals("foo", amqpItemReader.read());
    }
View Full Code Here

        assertEquals("foo", amqpItemReader.read());
    }

    @Test
    public void testNonMessageItemType() {
        final AmqpTemplate amqpTemplate = mock(AmqpTemplate.class);
        when(amqpTemplate.receiveAndConvert()).thenReturn("foo");

        final AmqpItemReader<String> amqpItemReader = new AmqpItemReader<String>(amqpTemplate);
        amqpItemReader.setItemType(String.class);

        assertEquals("foo", amqpItemReader.read());
View Full Code Here

    }

    @Test
    public void testMessageItemType() {
        final AmqpTemplate amqpTemplate = mock(AmqpTemplate.class);
        final Message message = mock(Message.class);

        when(amqpTemplate.receive()).thenReturn(message);

        final AmqpItemReader<Message> amqpItemReader = new AmqpItemReader<Message>(amqpTemplate);
        amqpItemReader.setItemType(Message.class);

        assertEquals(message, amqpItemReader.read());
View Full Code Here

    }

    @Test
    public void testTypeMismatch() {
        final AmqpTemplate amqpTemplate = mock(AmqpTemplate.class);

        when(amqpTemplate.receiveAndConvert()).thenReturn("foo");

        final AmqpItemReader<Integer> amqpItemReader = new AmqpItemReader<Integer>(amqpTemplate);
        amqpItemReader.setItemType(Integer.class);

        try {
View Full Code Here

    }

    @Test(expected = IllegalArgumentException.class)
    public void testNullItemType() {
        final AmqpTemplate amqpTemplate = mock(AmqpTemplate.class);

        final AmqpItemReader<String> amqpItemReader = new AmqpItemReader<String>(amqpTemplate);
        amqpItemReader.setItemType(null);
    }
View Full Code Here

        new AmqpItemWriter<String>(null);
    }

    @Test
    public void voidTestWrite() throws Exception {
        AmqpTemplate amqpTemplate = mock(AmqpTemplate.class);

        amqpTemplate.convertAndSend("foo");

        amqpTemplate.convertAndSend("bar");

        AmqpItemWriter<String> amqpItemWriter = new AmqpItemWriter<String>(amqpTemplate);
        amqpItemWriter.write(Arrays.asList("foo", "bar"));

    }
View Full Code Here

TOP

Related Classes of org.springframework.amqp.core.AmqpTemplate

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.