Search in sources :

Example 6 with StompFrame

use of org.fusesource.stomp.codec.StompFrame in project camel by apache.

the class StompEndpoint method doStop.

@Override
protected void doStop() throws Exception {
    connection.getDispatchQueue().execute(new Task() {

        @Override
        public void run() {
            StompFrame frame = new StompFrame(DISCONNECT);
            connection.send(frame, null);
        }
    });
    connection.close(null);
}
Also used : Task(org.fusesource.hawtdispatch.Task) StompFrame(org.fusesource.stomp.codec.StompFrame)

Example 7 with StompFrame

use of org.fusesource.stomp.codec.StompFrame in project camel by apache.

the class StompConsumerTest method testConsume.

@Test
public void testConsume() throws Exception {
    if (!canTest()) {
        return;
    }
    context.addRoutes(createRouteBuilder());
    context.start();
    Stomp stomp = createStompClient();
    final BlockingConnection producerConnection = stomp.connectBlocking();
    MockEndpoint mock = getMockEndpoint("mock:result");
    mock.expectedMinimumMessageCount(numberOfMessages);
    for (int i = 0; i < numberOfMessages; i++) {
        StompFrame frame = new StompFrame(SEND);
        frame.addHeader(DESTINATION, StompFrame.encodeHeader("/queue/test"));
        frame.addHeader(MESSAGE_ID, StompFrame.encodeHeader("msg:" + i));
        frame.content(utf8("Important Message " + i));
        producerConnection.send(frame);
    }
    mock.await(5, TimeUnit.SECONDS);
    mock.assertIsSatisfied();
}
Also used : MockEndpoint(org.apache.camel.component.mock.MockEndpoint) StompFrame(org.fusesource.stomp.codec.StompFrame) Stomp(org.fusesource.stomp.client.Stomp) BlockingConnection(org.fusesource.stomp.client.BlockingConnection) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) Test(org.junit.Test)

Example 8 with StompFrame

use of org.fusesource.stomp.codec.StompFrame in project camel by apache.

the class StompConsumerUriTest method testConsume.

@Test
public void testConsume() throws Exception {
    if (!canTest()) {
        return;
    }
    context.addRoutes(createRouteBuilder());
    context.start();
    Stomp stomp = createStompClient();
    final BlockingConnection producerConnection = stomp.connectBlocking();
    MockEndpoint mock = getMockEndpoint("mock:result");
    mock.expectedMinimumMessageCount(numberOfMessages);
    for (int i = 0; i < numberOfMessages; i++) {
        StompFrame frame = new StompFrame(SEND);
        frame.addHeader(DESTINATION, StompFrame.encodeHeader("/queue/test"));
        frame.addHeader(MESSAGE_ID, StompFrame.encodeHeader("msg:" + i));
        frame.content(utf8("Important Message " + i));
        producerConnection.send(frame);
    }
    mock.await(5, TimeUnit.SECONDS);
    mock.assertIsSatisfied();
}
Also used : MockEndpoint(org.apache.camel.component.mock.MockEndpoint) StompFrame(org.fusesource.stomp.codec.StompFrame) Stomp(org.fusesource.stomp.client.Stomp) BlockingConnection(org.fusesource.stomp.client.BlockingConnection) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) Test(org.junit.Test)

Aggregations

StompFrame (org.fusesource.stomp.codec.StompFrame)8 Task (org.fusesource.hawtdispatch.Task)5 Stomp (org.fusesource.stomp.client.Stomp)4 BlockingConnection (org.fusesource.stomp.client.BlockingConnection)3 Test (org.junit.Test)3 AsyncCallback (org.apache.camel.AsyncCallback)2 Exchange (org.apache.camel.Exchange)2 MockEndpoint (org.apache.camel.component.mock.MockEndpoint)2 Callback (org.fusesource.stomp.client.Callback)2 CountDownLatch (java.util.concurrent.CountDownLatch)1 Producer (org.apache.camel.Producer)1 CallbackConnection (org.fusesource.stomp.client.CallbackConnection)1 Promise (org.fusesource.stomp.client.Promise)1