use of org.apache.cxf.transport.jms.JMSConfiguration in project tesb-rt-se by Talend.
the class JmsConfiguratorTest method createAndConfigureDispatchAddressing.
@Test
public void createAndConfigureDispatchAddressing() {
Service service = Service.create(SERVICE_NAME);
service.addPort(PORT_NAME, SOAPBinding.SOAP11HTTP_BINDING, "jms://");
Dispatch<Source> dispatch = service.createDispatch(PORT_NAME, Source.class, Service.Mode.PAYLOAD);
Assert.assertNotNull(dispatch);
JmsConfigurator jmsConfigurator = JmsConfigurator.create(dispatch);
Assert.assertNotNull(jmsConfigurator);
Assert.assertEquals("SoapPort", jmsConfigurator.getConfigurationPrefix());
Assert.assertEquals(SERVICE_NAME, jmsConfigurator.getServiceName());
Dispatch<Source> dispatch2 = jmsConfigurator.configureDispatch(dispatch, "jms://");
Assert.assertNotNull(dispatch2);
Conduit conduit = ((DispatchImpl) dispatch2).getClient().getConduit();
Assert.assertNotNull(conduit);
Assert.assertTrue(conduit instanceof JMSConduit);
JMSConduit jmsConduit = (JMSConduit) conduit;
JMSConfiguration jmsConfiguration = jmsConduit.getJmsConfig();
Assert.assertNotNull(jmsConfiguration);
}
use of org.apache.cxf.transport.jms.JMSConfiguration in project tesb-rt-se by Talend.
the class JmsConfiguratorTest method testCreateAndConfigureEndpoint.
@Test
public void testCreateAndConfigureEndpoint() {
HelloWorldImpl2 implementor = new HelloWorldImpl2();
String address = "local://JmsUriConfiguratorTest";
ep = Endpoint.publish(address, implementor);
JmsConfigurator jmsConfigurator = JmsConfigurator.create(ep);
Assert.assertNotNull(jmsConfigurator);
Assert.assertEquals("HelloWorldImpl2Port", jmsConfigurator.getConfigurationPrefix());
Assert.assertEquals(SERVICE_NAME, jmsConfigurator.getServiceName());
JMSConfiguration jmsConf = new JMSConfiguration();
jmsConfigurator.setJmsConfiguration(jmsConf);
Endpoint ep2 = jmsConfigurator.configureEndpoint(ep);
Assert.assertNotNull(ep2);
Configuration cnf = jmsConfigurator.getConfiguration();
Assert.assertNotNull(cnf);
Assert.assertEquals("org.apache.activemq.jndi.ActiveMQInitialContextFactory", cnf.get("jndiInitialContextFactory"));
Assert.assertEquals("jndi", cnf.get("variant"));
Assert.assertEquals("ConnectionFactory", cnf.get("jndiConnectionFactoryName"));
Assert.assertEquals("tcp://localhost:61616", cnf.get("jndiURL"));
Assert.assertEquals("dynamicQueues/libraryprovider.queue", cnf.get("destinationName"));
List<Feature> features = ((EndpointImpl) ep2).getFeatures();
boolean jmsConfigFeaturePresent = false;
for (Feature f : features) {
if (f instanceof org.apache.cxf.transport.jms.JMSConfigFeature) {
jmsConfigFeaturePresent = true;
break;
}
}
Assert.assertTrue(jmsConfigFeaturePresent);
}
use of org.apache.cxf.transport.jms.JMSConfiguration in project tesb-rt-se by Talend.
the class JmsConfigurator method create.
public static JmsConfigurator create(JaxWsServerFactoryBean factory) {
if (factory == null) {
return null;
}
final QName serviceName = factory.getServiceName();
if (serviceName == null) {
return null;
}
final QName endpointName = factory.getEndpointName();
final String portName = endpointName == null ? null : endpointName.getLocalPart();
JmsConfigurator result = new JmsConfigurator();
result.setConfigurationPrefix(portName);
result.setJmsConfiguration(new JMSConfiguration());
result.setServiceName(serviceName);
return result;
}
use of org.apache.cxf.transport.jms.JMSConfiguration in project tesb-rt-se by Talend.
the class JmsConfigurator method configureJndi.
private void configureJndi(JMSConfiguration jmsConfiguration) {
final Configuration cfg = configuration == null ? CallContext.resolveConfiguration(serviceName) : configuration;
final String jndiConnectionFactoryName = getJndiProperty("jndiConnectionFactoryName");
if (jndiConnectionFactoryName != null) {
jmsConfiguration.setConnectionFactoryName(jndiConnectionFactoryName);
}
final String connectionUserName = getJndiProperty("connectionUserName");
if (connectionUserName != null) {
jmsConfiguration.setUserName(connectionUserName);
}
final String connectionPassword = getJndiProperty("connectionPassword");
if (connectionPassword != null) {
jmsConfiguration.setPassword(connectionPassword);
}
Properties env = jmsConfiguration.getJndiEnvironment();
final boolean hasNoEnv = env == null;
if (hasNoEnv) {
env = new Properties();
}
cfg.fillProperties("jndiConfig.environment", env);
if (workPrefix != null) {
cfg.fillProperties(workPrefix + "jndiConfig.environment", env);
}
if (hasNoEnv && !env.isEmpty()) {
jmsConfiguration.setJndiEnvironment(env);
}
}
use of org.apache.cxf.transport.jms.JMSConfiguration in project cxf by apache.
the class URIConfiguredConduitTest method sendAndReceive.
public void sendAndReceive(SyncType syncType, String address) throws Exception {
// Register bean locator for cf lookup
TestReceiver receiver = new TestReceiver(cf, SERVICE_QUEUE, false);
receiver.runAsync();
EndpointInfo ei = new EndpointInfo();
ei.setAddress(address);
Bus bus = BusFactory.getDefaultBus();
JMSConfiguration jmsConfig = JMSConfigFactory.createFromEndpointInfo(bus, ei, null);
jmsConfig.setConnectionFactory(cf);
JMSConduit conduit = new JMSConduit(new EndpointReferenceType(), jmsConfig, bus);
Exchange exchange = new ExchangeImpl();
exchange.setSynchronous(syncType == SyncType.sync);
Message message = new MessageImpl();
exchange.setOutMessage(message);
conduit.sendExchange(exchange, "Request");
waitForAsyncReply(exchange);
receiver.close();
assertNotNull("No reply received within 2 seconds", exchange.getInMessage());
JMSMessageHeadersType inHeaders = (JMSMessageHeadersType) exchange.getInMessage().get(JMSConstants.JMS_CLIENT_RESPONSE_HEADERS);
assertEquals(receiver.getRequestMessageId(), inHeaders.getJMSCorrelationID());
conduit.close();
}
Aggregations