Java Examples for org.apache.activemq.jndi.ActiveMQInitialContextFactory
The following java examples will help you to understand the usage of org.apache.activemq.jndi.ActiveMQInitialContextFactory. These source code samples are taken from different open source projects.
Example 1
Project: tesb-rt-se-master File: JMSHttpBookStore.java View source code |
private Context getContext() throws Exception {
ClassLoader loader = Thread.currentThread().getContextClassLoader();
try {
Properties props = new Properties();
props.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.activemq.jndi.ActiveMQInitialContextFactory");
props.setProperty(Context.PROVIDER_URL, "tcp://localhost:61616");
Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
return new InitialContext(props);
} finally {
Thread.currentThread().setContextClassLoader(loader);
}
}
Example 2
Project: carbon-registry-master File: Registry802Test.java View source code |
public void testEndpointUtils() throws RegistryException { String ep1 = EndpointUtils.deriveEndpointFromUrl("jms:/FunctionService?transport.jms.DestinationType=queue&transport.jms." + "ContentTypeProperty=Content-Type&java.naming.provider.url=" + "tcp://localhost:61618&java.naming.factory.initial=org.apache.activemq." + "jndi.ActiveMQInitialContextFactory&transport.jms." + "ConnectionFactoryJNDIName=QueueConnectionFactory"); System.out.println("Endpoint 1: " + ep1); String ep2 = EndpointUtils.deriveEndpointFromUrl("jms:/CharithaService?transport.jms.DestinationType=queue&transport.jms." + "ContentTypeProperty=Content-Type&java.naming.provider.url=" + "tcp://localhost:61618&java.naming.factory.initial=org.apache.activemq." + "jndi.ActiveMQInitialContextFactory&transport.jms." + "ConnectionFactoryJNDIName=QueueConnectionFactory"); System.out.println("Endpoint 2: " + ep2); assertFalse("The endpoints must be different", ep1.equals(ep2)); }
Example 3
Project: cxf-master File: URIConfiguredConduitTest.java View source code |
// @Ignoring due to continually failing on Jenkins
@Test
@org.junit.Ignore
public void testSendReceive() throws Exception {
sendAndReceive(SyncType.sync, "jms:jndi:dynamicQueues/" + SERVICE_QUEUE + "?jndiInitialContextFactory=org.apache.activemq.jndi.ActiveMQInitialContextFactory" + "&useConduitIdSelector=false" + "&replyToName=dynamicQueues/testreply" + "&messageType=text" + "&jndiConnectionFactoryName=ConnectionFactory" + "&jndiURL=" + BROKER_URI);
}
Example 4
Project: carbon-platform-integration-master File: JMSBrokerConfigurationProvider.java View source code |
/**
* This will return the Broker transport information according to transport name
* @param transportName name of the transport
* @return JMSBrokerConfiguration with the transport information
*/
private JMSBrokerConfiguration getJMSBrokerConfiguration(String transportName) {
if ("tcp".equalsIgnoreCase(transportName)) {
return tcp;
} else if ("mqtt".equalsIgnoreCase(transportName)) {
return mqtt;
} else {
JMSBrokerConfiguration jmsBrokerConfiguration = new JMSBrokerConfiguration();
jmsBrokerConfiguration.setInitialNamingFactory("org.apache.activemq.jndi.ActiveMQInitialContextFactory");
for (TransportConnector con : getTransportConnectors()) {
if (transportName.equalsIgnoreCase(con.getName())) {
jmsBrokerConfiguration.setProviderURL(con.getUri().toString());
}
}
return jmsBrokerConfiguration;
}
}
Example 5
Project: activemq-master File: AMQ3529v2Test.java View source code |
@Override
public void run() {
Context ctx = null;
Connection connection = null;
Session session = null;
MessageConsumer consumer = null;
try {
connection = connectionFactory.createConnection();
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
assertNotNull(session);
Properties props = new Properties();
props.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.activemq.jndi.ActiveMQInitialContextFactory");
props.setProperty(Context.PROVIDER_URL, connectionUri);
ctx = null;
try {
ctx = new InitialContext(props);
} catch (NoClassDefFoundError e) {
throw new NamingException(e.toString());
} catch (Exception e) {
throw new NamingException(e.toString());
}
Destination destination = (Destination) ctx.lookup("dynamicTopics/example.C");
consumer = session.createConsumer(destination);
consumer.receive(10000);
} catch (Exception e) {
} finally {
try {
if (consumer != null) {
consumer.close();
}
} catch (JMSException e) {
trackException("Consumer Close failed with", e);
}
try {
if (session != null) {
session.close();
}
} catch (JMSException e) {
trackException("Session Close failed with", e);
}
try {
if (connection != null) {
connection.close();
}
} catch (JMSException e) {
trackException("Connection Close failed with", e);
}
try {
if (ctx != null) {
ctx.close();
}
} catch (Exception e) {
trackException("Connection Close failed with", e);
}
}
}
Example 6
Project: product-esb-master File: JMSEndpointSuspensionViaVFSTest.java View source code |
private void addVFSJMSProxy1() throws Exception {
addProxyService(AXIOMUtil.stringToOM("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<proxy xmlns=\"http://ws.apache.org/ns/synapse\" name=\"VFSJMSProxy1\" transports=\"vfs\">\n" + " <parameter name=\"transport.vfs.FileURI\">file://" + getClass().getResource(File.separator + "artifacts" + File.separator + "ESB" + File.separator + "synapseconfig" + File.separator + "messageStore" + File.separator).getPath() + "test" + File.separator + "in" + File.separator + "</parameter> <!--CHANGE-->\n" + " <parameter name=\"transport.vfs.ContentType\">text/xml</parameter>\n" + " <parameter name=\"transport.vfs.FileNamePattern\">.*\\.xml</parameter>\n" + " <parameter name=\"transport.PollInterval\">1</parameter>\n" + " <parameter name=\"transport.vfs.ActionAfterProcess\">MOVE</parameter>\n" + " <parameter name=\"transport.vfs.MoveAfterProcess\">file://" + getClass().getResource(File.separator + "artifacts" + File.separator + "ESB" + File.separator + "synapseconfig" + File.separator + "messageStore" + File.separator).getPath() + "test" + File.separator + "done" + File.separator + "</parameter>" + " <parameter name=\"transport.vfs.MoveAfterFailure\">file://" + getClass().getResource(File.separator + "artifacts" + File.separator + "ESB" + File.separator + "synapseconfig" + File.separator + "messageStore" + File.separator).getPath() + "test" + File.separator + "invalid" + File.separator + "</parameter>\n" + " <parameter name=\"transport.vfs.ActionAfterFailure\">MOVE</parameter>" + " <target>\n" + " <inSequence>\n" + " <property name=\"OUT_ONLY\" value=\"true\" scope=\"default\" type=\"STRING\"/>\n" + " <log level=\"full\"/>\n" + " <send>\n" + " <endpoint>\n" + " <recipientlist>\n" + " <endpoint>\n" + " <address uri=\"jms:/Addresses?transport.jms.ConnectionFactoryJNDIName=QueueConnectionFactory&java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory&java.naming.provider.url=tcp://localhost:61616\"/>" + " </endpoint>" + " <endpoint>\n" + " <address uri=\"http://localhost:9654/services/SimpleStockQuoteService\"/>" + " </endpoint>" + " </recipientlist>\n" + " </endpoint>\n" + " </send>\n" + " </inSequence>\n" + " <faultSequence>\n" + " <log level=\"full\">\n" + " <property name=\"ERROR\" value=\"Endpoint Down!\"/>\n" + " </log>\n" + " <makefault>\n" + " <code value=\"tns:Sender\" xmlns:tns=\"http://www.w3.org/2003/05/soap-envelope\"/>\n" + " <reason value=\"Endpoint Down!\"/>\n" + " </makefault>\n" + " <send>\n" + " <endpoint>\n" + " <address uri=\"http://localhost:9654/services/SimpleStockQuoteService\"/>" + " </endpoint>" + " </send>\n" + " </faultSequence>" + " </target>\n" + " </proxy>"));
}
Example 7
Project: fcrepo-before33-master File: TestManagementNotifications.java View source code |
@Override
public void setUp() throws Exception {
apim = getFedoraClient().getAPIM();
// Create and start a subscriber
Properties props = new Properties();
props.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.activemq.jndi.ActiveMQInitialContextFactory");
props.setProperty(Context.PROVIDER_URL, "tcp://localhost:61616");
props.setProperty("topic.notificationTopic", "fedora.apim.update");
Context jndi = new InitialContext(props);
ConnectionFactory jmsConnectionFactory = (ConnectionFactory) jndi.lookup("ConnectionFactory");
jmsConnection = jmsConnectionFactory.createConnection();
jmsSession = jmsConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
destination = (Topic) jndi.lookup("notificationTopic");
messageConsumer = jmsSession.createConsumer(destination);
messageConsumer.setMessageListener(this);
jmsConnection.start();
}
Example 8
Project: jmsdigger-master File: JmsDumpDestinationTest.java View source code |
private InitialContext getInitialContext() throws JmsDiggerException {
JmsInitialContextFactory contextFactory = new JmsInitialContextFactory("org.apache.activemq.jndi.ActiveMQInitialContextFactory", "tcp://127.0.0.1:61616");
contextFactory.addConnectionFactory(connFactName);
contextFactory.addQueue(dumpQueue11Msgs, "jms." + dumpQueue11Msgs);
contextFactory.addQueue(dumpQueue00Msgs, "jms." + dumpQueue00Msgs);
contextFactory.addTopic(dumpTopic00Msgs, "jms." + dumpTopic00Msgs);
contextFactory.addTopic(dumpTopic11Msgs, "jms." + dumpTopic11Msgs);
contextFactory.addTopic(topic4DurableSubscriber, "jms." + topic4DurableSubscriber);
InitialContext ctxx = contextFactory.getInitialContext();
return ctxx;
}
Example 9
Project: winston_wolfe-master File: MockJMSBasedSystemUnderTestWithDynamicQueues.java View source code |
public void startServer() throws Exception {
Properties env = new Properties();
env.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.activemq.jndi.ActiveMQInitialContextFactory");
env.put(Context.PROVIDER_URL, "vm://localhost?broker.persistent=false");
InitialContext context = new InitialContext(env);
ConnectionFactory connectionFactory = (ConnectionFactory) context.lookup("ConnectionFactory");
conn = connectionFactory.createConnection();
conn.start();
session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
requestQueue = (Destination) context.lookup("dynamicQueues/requestQueue");
MessageConsumer consumer = session.createConsumer(requestQueue);
consumer.setMessageListener(this);
}
Example 10
Project: siddhi-master File: JMSSourceTestCase.java View source code |
@Test
public void TestJMSTopicSource() throws InterruptedException {
receivedEventNameList = new ArrayList<>(2);
// starting the ActiveMQ broker
ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(PROVIDER_URL);
// deploying the execution plan
SiddhiManager siddhiManager = new SiddhiManager();
String inStreamDefinition = "" + "@source(type='jms', @map(type='text'), " + "factory.initial='org.apache.activemq.jndi.ActiveMQInitialContextFactory', " + "provider.url='vm://localhost'," + "destination='DAS_JMS_TEST', " + "connection.factory.type='topic'," + "connection.factory.jndi.name='TopicConnectionFactory'," + "transport.jms.SubscriptionDurable='true', " + "transport.jms.DurableSubscriberClientID='wso2dasclient1'" + ")" + "define stream inputStream (name string, age int, country string);";
String query = ("@info(name = 'query1') " + "from inputStream " + "select * " + "insert into outputStream;");
ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(inStreamDefinition + query);
executionPlanRuntime.addCallback("query1", new QueryCallback() {
@Override
public void receive(long timeStamp, Event[] inEvents, Event[] removeEvents) {
EventPrinter.print(timeStamp, inEvents, removeEvents);
for (Event event : inEvents) {
receivedEventNameList.add(event.getData(0).toString());
}
}
});
executionPlanRuntime.start();
// publishing events
publishEvents("DAS_JMS_TEST", null, "activemq", "text", "src/test/resources/events/events_text.txt");
List<String> expected = new ArrayList<>(2);
expected.add("\nJohn");
expected.add("\nMike");
Assert.assertEquals("JMS Source expected input not received", expected, receivedEventNameList);
}
Example 11
Project: choreos_middleware-master File: ThresholdEvalDaemonService.java View source code |
public Properties getProperties() {
if (probeSettingsProperties == null) {
probeSettingsProperties = Manager.createProbeSettingsPropertiesObject("org.apache.activemq.jndi.ActiveMQInitialContextFactory", javaNamingProviderUrl, "system", "manager", "TopicCF", "jms.probeTopic", false, "probeName", "probeTopic");
}
return probeSettingsProperties;
}
Example 12
Project: fedora-client-master File: MessagingClientIT.java View source code |
@Before
public void setUp() throws Exception {
properties = new Properties();
properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.activemq.jndi.ActiveMQInitialContextFactory");
properties.setProperty(Context.PROVIDER_URL, System.getProperty("broker.uri"));
properties.setProperty(JMSManager.CONNECTION_FACTORY_NAME, "ConnectionFactory");
properties.setProperty("topic." + TOPIC_NAME, TOPIC);
properties.setProperty("queue." + QUEUE_NAME, QUEUE);
}
Example 13
Project: droolsjbpm-master File: SimpleProducer.java View source code |
public void simpleProducer2() {
Context jndiContext = null;
ConnectionFactory connectionFactory = null;
Connection connection = null;
Session session = null;
Destination destination = null;
MessageProducer producer = null;
String destinationName = "dynamicQueues/FOO.BAR";
final int numMsgs = 50;
System.out.println("Destination name is " + destinationName);
/*
* Create a JNDI API InitialContext object
*/
try {
Properties props = new Properties();
props.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.activemq.jndi.ActiveMQInitialContextFactory");
props.setProperty(Context.PROVIDER_URL, "vm://localhost:61616");
jndiContext = new InitialContext(props);
} catch (NamingException e) {
e.printStackTrace();
System.out.println("Could not create JNDI API context: " + e.toString());
System.exit(1);
}
/*
* Look up connection factory and destination.
*/
try {
connectionFactory = (ConnectionFactory) jndiContext.lookup("ConnectionFactory");
destination = (Destination) jndiContext.lookup(destinationName);
} catch (NamingException e) {
e.printStackTrace();
System.exit(1);
}
/*
* Create connection. Create session from connection; false means
* session is not transacted. Create sender and text message. Send
* messages, varying text slightly. Send end-of-messages message.
* Finally, close connection.
*/
try {
connection = connectionFactory.createConnection();
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
//session.createTopic( "" )
producer = session.createProducer(destination);
TextMessage message = session.createTextMessage();
for (int i = 0; i < numMsgs; i++) {
message.setText("This is message " + (i + 1));
System.out.println("Sending message: " + message.getText());
producer.send(message);
}
/*
* Send a non-text control message indicating end of messages.
*/
producer.send(session.createMessage());
} catch (JMSException e) {
e.printStackTrace();
System.out.println("Exception occurred: " + e);
} finally {
if (connection != null) {
try {
connection.close();
} catch (JMSException e) {
}
}
}
}
Example 14
Project: camel-master File: CxfEndpointJMSConsumerTest.java View source code |
@Test
public void testInvocation() {
// Here we just the address with JMS URI
String address = "jms:jndi:dynamicQueues/test.cxf.jmstransport.queue" + "?jndiInitialContextFactory" + "=org.apache.activemq.jndi.ActiveMQInitialContextFactory" + "&jndiConnectionFactoryName=ConnectionFactory&jndiURL=" + "vm://localhost";
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
factory.setServiceClass(Greeter.class);
factory.setAddress(address);
Greeter greeter = factory.create(Greeter.class);
String response = greeter.greetMe("Willem");
assertEquals("Get a wrong response", "Hello Willem", response);
}
Example 15
Project: hibernate-search-master File: JMSMasterTest.java View source code |
private Context getJndiInitialContext() throws NamingException {
Properties props = new Properties();
props.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.activemq.jndi.ActiveMQInitialContextFactory");
props.setProperty(Context.PROVIDER_URL, "vm://localhost");
props.setProperty("connectionFactoryNames", "ConnectionFactory, java:/ConnectionFactory");
props.setProperty("queue.queue/searchtest", "searchQueue");
return new javax.naming.InitialContext(props);
}
Example 16
Project: logging-log4j2-master File: JmsAppenderIT.java View source code |
@BeforeClass
public static void setUpClass() {
System.setProperty(KEY_SERIALIZABLE_PACKAGES, "org.apache.logging.log4j.core.impl,org.apache.logging.log4j.util,org.apache.logging.log4j");
final Properties additional = new Properties();
additional.setProperty("queue.TestQueue", "TestQueue");
final JndiManager jndiManager = JndiManager.getJndiManager(ActiveMQInitialContextFactory.class.getName(), "vm://localhost?broker.persistent=false", null, null, null, additional);
jmsManager = JmsManager.getJmsManager("JmsManager", jndiManager, "ConnectionFactory", "TestQueue", null, null);
}
Example 17
Project: hive-master File: TestNotificationListener.java View source code |
@Before
public void setUp() throws Exception {
System.setProperty("java.naming.factory.initial", "org.apache.activemq.jndi.ActiveMQInitialContextFactory");
System.setProperty("java.naming.provider.url", "vm://localhost?broker.persistent=false");
ConnectionFactory connFac = new ActiveMQConnectionFactory("vm://localhost?broker.persistent=false");
Connection conn = connFac.createConnection();
conn.start();
// We want message to be sent when session commits, thus we run in
// transacted mode.
Session session = conn.createSession(true, Session.SESSION_TRANSACTED);
Destination hcatTopic = session.createTopic(HCatConstants.HCAT_DEFAULT_TOPIC_PREFIX);
MessageConsumer consumer1 = session.createConsumer(hcatTopic);
consumer1.setMessageListener(this);
Destination tblTopic = session.createTopic(HCatConstants.HCAT_DEFAULT_TOPIC_PREFIX + ".mydb.mytbl");
MessageConsumer consumer2 = session.createConsumer(tblTopic);
consumer2.setMessageListener(this);
Destination dbTopic = session.createTopic(HCatConstants.HCAT_DEFAULT_TOPIC_PREFIX + ".mydb");
MessageConsumer consumer3 = session.createConsumer(dbTopic);
consumer3.setMessageListener(this);
setUpHiveConf();
hiveConf.set(ConfVars.METASTORE_EVENT_LISTENERS.varname, NotificationListener.class.getName());
hiveConf.setVar(HiveConf.ConfVars.HIVE_AUTHORIZATION_MANAGER, "org.apache.hadoop.hive.ql.security.authorization.plugin.sqlstd.SQLStdHiveAuthorizerFactory");
SessionState.start(new CliSessionState(hiveConf));
driver = new Driver(hiveConf);
client = new HiveMetaStoreClient(hiveConf);
}
Example 18
Project: rayo-server-master File: BaseProvisioningAgentTest.java View source code |
DefaultJmsNotificationService createNotificationService() throws Exception {
final DefaultJmsNotificationService jmsNotificationService = new DefaultJmsNotificationService();
HashMap<String, String> env = new HashMap<String, String>();
env.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.activemq.jndi.ActiveMQInitialContextFactory");
env.put(Context.PROVIDER_URL, "vm://localhost?broker.persistent=false");
jmsNotificationService.setEnvironment(env);
jmsNotificationService.setTopic("VirtualTopic.Provisioning");
jmsNotificationService.setConnectionFactory("TopicConnectionFactory");
jmsNotificationService.setSipDomain("sip.tropo.com");
jmsNotificationService.setRetryInterval(1000);
jmsNotificationService.setRetries(10);
jmsNotificationService.init();
return jmsNotificationService;
}
Example 19
Project: jcloudscale-master File: JMSConnectionHolder.java View source code |
//-------- STATIC METHODS ------------------------------
private static Context createContext(String address, int serverPort, long messageSizeLimit) throws NamingException {
Properties props = new Properties();
props.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.activemq.jndi.ActiveMQInitialContextFactory");
String providerUrl = "tcp://" + address + ":" + serverPort;
if (messageSizeLimit > 0)
providerUrl += "?wireFormat.maxFrameSize=" + messageSizeLimit;
props.setProperty(Context.PROVIDER_URL, providerUrl);
return new InitialContext(props);
}