use of cbit.vcell.message.jms.activeMQ.VCMessagingServiceActiveMQ in project vcell by virtualcell.
the class TestBlobRpcMessages method main.
public static void main(String[] args) throws Exception {
try {
PropertyLoader.loadProperties();
// System.getProperties().setProperty(PropertyLoader.jmsURL,"tcp://nrcamdev5.cam.uchc.edu:61616");
VCMessagingService messagingService = new VCMessagingServiceActiveMQ();
messagingService.setDelegate(new SimpleMessagingDelegate());
// reading message and computing sum
// create N comsumers
MyRpcServer myRpcServer = new MyRpcServer();
for (int i = 0; i < NUM_COMSUMERS; i++) {
VCRpcMessageHandler rpcMessageHandler = new VCRpcMessageHandler(myRpcServer, VCellTestQueue.JimQueue);
VCQueueConsumer rpcConsumer = new VCQueueConsumer(VCellTestQueue.JimQueue, rpcMessageHandler, null, "Queue[" + VCellTestQueue.JimQueue.getName() + "] ==== RPC Consumer Thread " + i, 1);
messagingService.addMessageConsumer(rpcConsumer);
}
// creating one messageProducer session
ArrayList<VCMessageSession> sessions = new ArrayList<VCMessageSession>();
for (int i = 0; i < NUM_PRODUCERS; i++) {
sessions.add(messagingService.createProducerSession());
}
for (int i = 0; i < NUM_MESSAGES; i++) {
for (int s = 0; s < NUM_PRODUCERS; s++) {
VCMessageSession session = sessions.get(s);
try {
//
// create simple RPC request for service "Testing_Service"
//
User user = new User("schaff", new KeyValue("17"));
byte[] array1 = new byte[20000000];
byte[] array2 = new byte[20000000];
VCRpcRequest rpcRequest = new VCRpcRequest(user, RpcServiceType.TESTING_SERVICE, "concat", new Object[] { array1, array2 });
//
// send request and block for response (or timeout).
// RPC invocations don't need commits.
//
Object returnValue = session.sendRpcMessage(VCellTestQueue.JimQueue, rpcRequest, true, 20000, null, null, null);
//
if (returnValue instanceof byte[]) {
System.out.println("concat(byte[" + array1.length + "], byte[" + array2.length + "]) ===> byte[" + (((byte[]) returnValue).length) + "]");
} else {
System.out.println("unexpected return value of " + returnValue);
}
} catch (VCMessagingInvocationTargetException e) {
e.printStackTrace(System.out);
System.out.println("the rpc service threw an exception");
e.getTargetException().printStackTrace(System.out);
}
}
}
System.out.println("main program calling closeAll()");
messagingService.close();
System.out.println("main program exiting");
} catch (Exception e) {
e.printStackTrace(System.out);
}
}
use of cbit.vcell.message.jms.activeMQ.VCMessagingServiceActiveMQ in project vcell by virtualcell.
the class TestBlobMessages method setUp.
@Before
public void setUp() throws Exception {
System.getProperties().put("vcell.mongodb.host", "localhost");
System.getProperties().put("vcell.mongodb.port", "27017");
System.getProperties().put("vcell.mongodb.database", "test");
mongoDbDriver = VCMongoDbDriver.getInstance();
System.getProperties().put("vcell.jms.url", "failover:(tcp://localhost:61616)");
System.getProperties().put("vcell.jms.user", "clientUser");
System.getProperties().put("vcell.jms.pswdfile", "~/vcellkeys/jmspswd.txt");
System.getProperties().put("vcell.jms.blobMessageUseMongo", "true");
System.getProperties().put("vcell.jms.blobMessageMinSize", "100000");
messagingService = new VCMessagingServiceActiveMQ();
messagingService.setDelegate(new SimpleMessagingDelegate());
}
Aggregations