Search in sources :

Example 11 with Message

use of org.jboss.narayana.blacktie.jatmibroker.core.transport.Message in project narayana by jbosstm.

the class TestConnection method test.

public void test() throws ConnectionException, IOException {
    Receiver serviceDispatcher = serviceTransport.getReceiver("JAVA_Converse", false);
    Sender clientSender = clientTransport.getSender("JAVA_Converse", false);
    Receiver clientReceiver = clientTransport.createReceiver(1, null, null);
    clientSender.send(clientReceiver.getReplyTo(), (short) 1, 1, "hi".getBytes(), 2, 0, 0, 0, "X_OCTET", null);
    Message receive = serviceDispatcher.receive(0);
    receive.ack();
    assertTrue(receive.len == 2);
    Sender serviceSender = serviceTransport.createSender(receive.replyTo);
    Receiver serviceReceiver = serviceTransport.createReceiver(1, null, null);
    log.info("Chatting");
    for (int i = 0; i < 100; i++) {
        String toSend = String.valueOf(i);
        serviceSender.send(serviceReceiver.getReplyTo(), (short) 1, 1, toSend.getBytes(), toSend.length(), 0, 0, 0, "X_OCTET", null);
        Message receive2 = clientReceiver.receive(0);
        assertTrue(receive2.len == toSend.length());
        String received = new String(receive2.data);
        assertTrue(received + " " + toSend, received.equals(toSend));
    }
    log.info("Chatted");
}
Also used : Sender(org.jboss.narayana.blacktie.jatmibroker.core.transport.Sender) Message(org.jboss.narayana.blacktie.jatmibroker.core.transport.Message) Receiver(org.jboss.narayana.blacktie.jatmibroker.core.transport.Receiver)

Aggregations

Message (org.jboss.narayana.blacktie.jatmibroker.core.transport.Message)11 ConnectionException (org.jboss.narayana.blacktie.jatmibroker.xatmi.ConnectionException)5 IOException (java.io.IOException)4 Receiver (org.jboss.narayana.blacktie.jatmibroker.core.transport.Receiver)3 DataInputStream (java.io.DataInputStream)2 EOFException (java.io.EOFException)2 SocketException (java.net.SocketException)2 Sender (org.jboss.narayana.blacktie.jatmibroker.core.transport.Sender)2 ResponseException (org.jboss.narayana.blacktie.jatmibroker.xatmi.ResponseException)2 DataOutputStream (java.io.DataOutputStream)1 Socket (java.net.Socket)1 Properties (java.util.Properties)1 CodecFactory (org.jboss.narayana.blacktie.jatmibroker.codec.CodecFactory)1 ResponseMonitor (org.jboss.narayana.blacktie.jatmibroker.core.ResponseMonitor)1 AtmiBrokerEnvXML (org.jboss.narayana.blacktie.jatmibroker.core.conf.AtmiBrokerEnvXML)1 Codec (org.jboss.narayana.blacktie.jatmibroker.core.transport.Codec)1 EventListener (org.jboss.narayana.blacktie.jatmibroker.core.transport.EventListener)1 Transport (org.jboss.narayana.blacktie.jatmibroker.core.transport.Transport)1 TransportFactory (org.jboss.narayana.blacktie.jatmibroker.core.transport.TransportFactory)1 TransactionException (org.jboss.narayana.blacktie.jatmibroker.core.tx.TransactionException)1