use of org.jboss.narayana.blacktie.jatmibroker.core.transport.Sender in project narayana by jbosstm.
the class TransportImpl method createSender.
public Sender createSender(Object destination) throws ConnectionException {
if (closed) {
log.error("Already closed");
throw new ConnectionException(Connection.TPEPROTO, "Already closed");
}
Sender sender;
String callback_ior = (String) destination;
log.debug("Creating a sender for: " + callback_ior);
if (callback_ior.contains("IOR:")) {
log.debug(callback_ior + " is for corba");
throw new ConnectionException(org.jboss.narayana.blacktie.jatmibroker.xatmi.Connection.TPESYSTEM, "Could not create a Corba sender");
} else {
log.debug(callback_ior + " is for socket");
sender = new SocketSenderImpl(callback_ior);
}
log.debug("Created sender");
return sender;
}
use of org.jboss.narayana.blacktie.jatmibroker.core.transport.Sender in project narayana by jbosstm.
the class TransportImpl method getSender.
public Sender getSender(String serviceName, boolean conversational) throws ConnectionException {
if (closed) {
log.error("Already closed");
throw new ConnectionException(Connection.TPEPROTO, "Already closed");
}
log.debug("Get sender: " + serviceName);
Map<String, Sender> conversationalMap = senders.get(conversational);
if (conversationalMap == null) {
conversationalMap = new HashMap<String, Sender>();
senders.put(conversational, conversationalMap);
}
Sender toReturn = conversationalMap.get(serviceName);
if (toReturn == null) {
try {
String type = (String) properties.get("blacktie." + serviceName + ".type");
toReturn = new StompSenderImpl(serviceName, conversational, type, conversationalMap, properties);
conversationalMap.put(serviceName, toReturn);
} catch (ConnectionException e) {
throw e;
} catch (Throwable t) {
throw new ConnectionException(org.jboss.narayana.blacktie.jatmibroker.xatmi.Connection.TPESYSTEM, "Could not create a service sender: " + t.getMessage(), t);
}
}
return toReturn;
}
use of org.jboss.narayana.blacktie.jatmibroker.core.transport.Sender in project narayana by jbosstm.
the class ConnectionImplTest method test.
public void test() throws Exception {
AtmiBrokerEnvXML xml = new AtmiBrokerEnvXML();
Properties properties = xml.getProperties();
TransportFactory factory = new TransportFactory(properties);
Transport proxy = factory.createTransport();
Sender serviceFactory = proxy.getSender("BAR", false);
String aString = "Hello from Java Land";
Receiver endpoint = proxy.createReceiver(1, null, null);
serviceFactory.send(endpoint.getReplyTo(), (short) 0, 0, aString.getBytes(), aString.getBytes().length, 0, 0, 0, "X_OCTET", "");
Message receive = endpoint.receive(0);
assertNotNull(receive);
String string = new String(receive.data).intern();
String expectedResponse = "BAR SAYS HELLO";
log.debug("Bar ServiceManager service_request response is " + string);
log.debug("Bar ServiceManager service_request size of response is " + receive.len);
assertEquals(string, expectedResponse);
proxy.close();
factory.close();
}
use of org.jboss.narayana.blacktie.jatmibroker.core.transport.Sender 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");
}
Aggregations