use of org.apache.cxf.hello_world_jms.HelloWorldOneWayPort in project cxf by apache.
the class GreeterImplQueueDecoupledOneWays method sendReply.
protected void sendReply() {
JMSMessageHeadersType headers = (JMSMessageHeadersType) context.getMessageContext().get(JMSConstants.JMS_SERVER_REQUEST_HEADERS);
if (headers == null || headers.getJMSReplyTo() == null) {
synchronized (this) {
if (!specCompliant) {
asyncEx = new Exception("ReplyTo header in the server Request context was null");
}
notifyAll();
}
return;
} else if (headers != null && headers.getJMSReplyTo() != null && specCompliant) {
synchronized (this) {
asyncEx = new Exception("ReplyTo header in the server Request context was not null");
notifyAll();
}
return;
}
QName serviceName = new QName("http://cxf.apache.org/hello_world_jms", "HelloWorldQueueDecoupledOneWaysService");
QName portName = new QName("http://cxf.apache.org/hello_world_jms", "HelloWorldQueueDecoupledOneWaysReplyPort");
Throwable e = null;
try {
URL wsdl = getClass().getResource("/wsdl/jms_test.wsdl");
HelloWorldQueueDecoupledOneWaysService service = new HelloWorldQueueDecoupledOneWaysService(wsdl, serviceName);
HelloWorldOneWayPort greeter = service.getPort(portName, HelloWorldOneWayPort.class);
reply = "Re:" + request;
greeter.greetMeOneWay(reply);
} catch (Throwable t) {
e = t;
}
synchronized (this) {
asyncEx = e;
notifyAll();
}
}
use of org.apache.cxf.hello_world_jms.HelloWorldOneWayPort in project cxf by apache.
the class JMSClientServerTest method testQueueDecoupledOneWaysConnection.
@Test
public void testQueueDecoupledOneWaysConnection() throws Exception {
QName serviceName = new QName("http://cxf.apache.org/hello_world_jms", "HelloWorldQueueDecoupledOneWaysService");
QName portName = new QName("http://cxf.apache.org/hello_world_jms", "HelloWorldQueueDecoupledOneWaysPort");
URL wsdl = getWSDLURL("/wsdl/jms_test.wsdl");
String wsdl2 = "testutils/jms_test.wsdl".intern();
wsdlStrings.add(wsdl2);
broker.updateWsdl(getBus(), wsdl2);
HelloWorldQueueDecoupledOneWaysService service = new HelloWorldQueueDecoupledOneWaysService(wsdl, serviceName);
Endpoint requestEndpoint = null;
Endpoint replyEndpoint = null;
HelloWorldOneWayPort greeter = service.getPort(portName, HelloWorldOneWayPort.class);
try {
GreeterImplQueueDecoupledOneWays requestServant = new GreeterImplQueueDecoupledOneWays();
requestEndpoint = Endpoint.publish(null, requestServant, new LoggingFeature());
GreeterImplQueueDecoupledOneWaysDeferredReply replyServant = new GreeterImplQueueDecoupledOneWaysDeferredReply();
replyEndpoint = Endpoint.publish(null, replyServant, new LoggingFeature());
BindingProvider bp = (BindingProvider) greeter;
Map<String, Object> requestContext = bp.getRequestContext();
JMSMessageHeadersType requestHeader = new JMSMessageHeadersType();
requestHeader.setJMSReplyTo("dynamicQueues/test.jmstransport.oneway.with.set.replyto.reply");
requestContext.put(JMSConstants.JMS_CLIENT_REQUEST_HEADERS, requestHeader);
String expectedRequest = "JMS:Queue:Request";
greeter.greetMeOneWay(expectedRequest);
String request = requestServant.ackRequestReceived(5000);
if (request == null) {
if (requestServant.getException() != null) {
fail(requestServant.getException().getMessage());
} else {
fail("The oneway call didn't reach its intended endpoint");
}
}
assertEquals(expectedRequest, request);
requestServant.proceedWithReply();
String expectedReply = requestServant.ackReplySent(5000);
if (expectedReply == null) {
if (requestServant.getException() != null) {
fail(requestServant.getException().getMessage());
} else {
fail("The decoupled one-way reply was not sent");
}
}
String reply = replyServant.ackRequest(5000);
if (reply == null) {
if (replyServant.getException() != null) {
fail(replyServant.getException().getMessage());
} else {
fail("The decoupled one-way reply didn't reach its intended endpoint");
}
}
assertEquals(expectedReply, reply);
} catch (Exception ex) {
throw ex;
} finally {
if (requestEndpoint != null) {
requestEndpoint.stop();
}
if (replyEndpoint != null) {
replyEndpoint.stop();
}
((java.io.Closeable) greeter).close();
}
}
use of org.apache.cxf.hello_world_jms.HelloWorldOneWayPort in project cxf by apache.
the class JMSClientServerTest method testQueueOneWaySpecCompliantConnection.
@Test
public void testQueueOneWaySpecCompliantConnection() throws Throwable {
QName serviceName = new QName("http://cxf.apache.org/hello_world_jms", "HelloWorldQueueDecoupledOneWaysService");
QName portName = new QName("http://cxf.apache.org/hello_world_jms", "HelloWorldQueueDecoupledOneWaysPort");
URL wsdl = getWSDLURL("/wsdl/jms_test.wsdl");
assertNotNull(wsdl);
String wsdlString2 = "testutils/jms_test.wsdl";
wsdlStrings.add(wsdlString2);
broker.updateWsdl(getBus(), wsdlString2);
HelloWorldQueueDecoupledOneWaysService service = new HelloWorldQueueDecoupledOneWaysService(wsdl, serviceName);
assertNotNull(service);
Endpoint requestEndpoint = null;
HelloWorldOneWayPort greeter = service.getPort(portName, HelloWorldOneWayPort.class);
try {
GreeterImplQueueDecoupledOneWays requestServant = new GreeterImplQueueDecoupledOneWays(true);
requestEndpoint = Endpoint.publish(null, requestServant);
BindingProvider bp = (BindingProvider) greeter;
Map<String, Object> requestContext = bp.getRequestContext();
JMSMessageHeadersType requestHeader = new JMSMessageHeadersType();
requestHeader.setJMSReplyTo("dynamicQueues/test.jmstransport.oneway.with.set.replyto.reply");
requestContext.put(JMSConstants.JMS_CLIENT_REQUEST_HEADERS, requestHeader);
String expectedRequest = "JMS:Queue:Request";
greeter.greetMeOneWay(expectedRequest);
String request = requestServant.ackRequestReceived(5000);
if (request == null) {
if (requestServant.getException() != null) {
fail(requestServant.getException().getMessage());
} else {
fail("The oneway call didn't reach its intended endpoint");
}
}
assertEquals(expectedRequest, request);
requestServant.proceedWithReply();
boolean ack = requestServant.ackNoReplySent(5000);
if (!ack) {
if (requestServant.getException() != null) {
Throwable ex = requestServant.getException();
if (ex.getMessage().contains("Request context was not null")) {
return;
}
throw requestServant.getException();
}
fail("The decoupled one-way reply was sent");
}
} catch (Exception ex) {
throw ex;
} finally {
if (requestEndpoint != null) {
requestEndpoint.stop();
}
((java.io.Closeable) greeter).close();
}
}
use of org.apache.cxf.hello_world_jms.HelloWorldOneWayPort in project cxf by apache.
the class JMSClientServerTest method testOneWayQueueConnection.
@Test
public void testOneWayQueueConnection() throws Exception {
QName serviceName = new QName("http://cxf.apache.org/hello_world_jms", "HelloWorldOneWayQueueService");
QName portName = new QName("http://cxf.apache.org/hello_world_jms", "HelloWorldOneWayQueuePort");
URL wsdl = getWSDLURL("/wsdl/jms_test.wsdl");
HelloWorldOneWayQueueService service = new HelloWorldOneWayQueueService(wsdl, serviceName);
HelloWorldOneWayPort greeter = service.getPort(portName, HelloWorldOneWayPort.class, new AddressingFeature(true, true));
for (int idx = 0; idx < 5; idx++) {
greeter.greetMeOneWay("JMS:Queue:Milestone-" + idx);
}
// Give some time to complete one-way calls.
Thread.sleep(100L);
((java.io.Closeable) greeter).close();
}
use of org.apache.cxf.hello_world_jms.HelloWorldOneWayPort in project cxf by apache.
the class JMSClientServerTest method testConnectionsWithinSpring.
@Test
public void testConnectionsWithinSpring() throws Exception {
BusFactory.setDefaultBus(null);
BusFactory.setThreadDefaultBus(null);
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(new String[] { "/org/apache/cxf/systest/jms/JMSClients.xml" });
try {
String wsdlString2 = "classpath:wsdl/jms_test.wsdl";
wsdlStrings.add(wsdlString2);
broker.updateWsdl((Bus) ctx.getBean("cxf"), wsdlString2);
HelloWorldPortType greeter = (HelloWorldPortType) ctx.getBean("jmsRPCClient");
try {
for (int idx = 0; idx < 5; idx++) {
String greeting = greeter.greetMe("Milestone-" + idx);
assertNotNull("no response received from service", greeting);
String exResponse = "Hello Milestone-" + idx;
assertEquals(exResponse, greeting);
String reply = greeter.sayHi();
assertEquals("Bonjour", reply);
try {
greeter.testRpcLitFault("BadRecordLitFault");
fail("Should have thrown BadRecoedLitFault");
} catch (BadRecordLitFault ex) {
assertNotNull(ex.getFaultInfo());
}
try {
greeter.testRpcLitFault("NoSuchCodeLitFault");
fail("Should have thrown NoSuchCodeLitFault exception");
} catch (NoSuchCodeLitFault nslf) {
assertNotNull(nslf.getFaultInfo());
assertNotNull(nslf.getFaultInfo().getCode());
}
}
} catch (UndeclaredThrowableException ex) {
ctx.close();
throw (Exception) ex.getCause();
}
HelloWorldOneWayPort greeter1 = (HelloWorldOneWayPort) ctx.getBean("jmsQueueOneWayServiceClient");
assertNotNull(greeter1);
try {
greeter1.greetMeOneWay("hello");
} catch (Exception ex) {
fail("There should not throw the exception" + ex);
}
} finally {
ctx.close();
BusFactory.setDefaultBus(getBus());
BusFactory.setThreadDefaultBus(getBus());
}
}
Aggregations