System.out.println("OutboundConsumer ok");
oc.start();
System.out.println();
System.out.println("Without MessageListener");
TextMessage msg = os.createTextMessage("avec queue");
prod.send(msg);
TextMessage msg1 =(TextMessage) cons.receive();
System.out.println("msg receive :"+msg1.getText());
System.out.println();
System.out.println("With MessageListener");
MessagePointFactory mep = new MessagePointFactory();
ActivationSpecImpl spec = new ActivationSpecImpl();
spec.setResourceAdapter(ja);
spec.setDestinationType("javax.jms.Queue");
spec.setDestination("queue");
MessagePointFactory mep2 = new MessagePointFactory();
ActivationSpecImpl spec2 = new ActivationSpecImpl();
spec2.setResourceAdapter(ja);
spec2.setDestinationType("javax.jms.Topic");
spec2.setDestination("topic");
ja.endpointActivation(mep , spec); // listener on queue
ja.endpointActivation(mep2 , spec2);// listener on topic
System.out.println("new thread producer on queue");
new Thread() {
public void run() {
int i = 0;
try {
while(i!=100){
i++;
TextMessage msg = os.createTextMessage("with queue "+i);
prod.send(msg);
}
} catch (Exception exc) {
}
}
}.start();
System.out.println("new thread producer on topic");
new Thread() {
public void run() {
int i = 0;
try {
while(i!=100){
i++;
TextMessage msg = os.createTextMessage("with topic2 "+i);
prod1.send(msg);
}
} catch (Exception exc) {
}