How to use ECF JMS/ActiveMQ provider with remote services? - jms

In order to make an OSGI service to be remotely accessible, I'd like to use ActiveMQ JMS broker as a distribution provider inside ECF framework. Which steps should I take?

I'll be answering my own question in order to document it.
Get a minimal working ECF remote service workspace, with ecf.generic.server as the distribution and one of the discovery providers (zookeeper for example). You can use http://wiki.eclipse.org/EIG:Getting_Started_with_OSGi_Remote_Services tutorial.
Install an ActiveMQ broker with default configuration.
Download the JMS/ActiveMQ ECF providers from https://github.com/ECF/JMS. Add the org.eclipse.ecf.provider.jms and org.eclipse.ecf.provider.jms.activemq projects in your workspace, build and add them to your run configuration or target platform.
For the provider service properties, do the following changes:
a. Change the "service.exported.configs" property for as "ecf.jms.activemq.tcp.client"
b. Add "ecf.endpoint.connecttarget.id" property with the following value "tcp://[ACTIVEMQ_IP]:61616/rs_topic", replacing [ACTIVEMQ_IP] with the broker IP. You can also change the topic name as something related to your service.
Now we also need a ActiveMQ JMS Server Container. Add the following code to the provider side. Use the Activator or fire up a new component with DS. You can also get an IContainerFactory object from the service registry.
IContainerFactory containerFactory = ContainerFactory.getDefault();
containerFactory.createContainer("ecf.jms.activemq.tcp.manager",
new Object[] { "tcp://[ACTIVEMQ_IP]:61616/rs_topic" });

Related

How to get qpid broker URL programmatically?

So I have a ConnectionFactory configured from a properties file containing a broker list, meaning that when the session gets created it will have connected to one of the brokers in the list based on availability/policy and so on.
My question is: how to programmatically figure out from the Java code, at runtime, which of the broker URLs have I actually connected to.
What I am trying to achieve is to send management GET requests to the broker API programmatically, but for that I need to obtain its URL. Am I thinking about this the wrong way?
P.S. I am doing this from a Spring-boot application, but am not too fussed about using the JmsTemplate.

Remote Declarative Services In Equinox

I'm trying to provide a remote declarative service using Eclipse ECF.
In the service provider component definition, I have set the following properties:
service.exported.interfaces = *
service.exported.configs = ecf.generic.server
ecf.generic.server.id = ecftcp://localhost:3787/server
However I can't figure out how to discover the service using these properties from the consumer side.
(I want to be able to provide the service from one osgi environment and discover it from another osgi.)
Discovery will run automatically if you have specified "service.exported.interfaces". For this to work you need to have the ECF discovery bundles installed in both your targets. On top of this you have to choose a discovery provider. Like SLP, JmDNS or Zookeeper.
Please note that some discovery providers need additional properties to run correctly. For example if you have a double network you need to specify in the JmDNS provider on which network the discovery has to listen.
Make sure that the ECF distribution bundle is started. This does not start automatically.

Deploy MDB on WebLogic 10.3

I am new to MDB, so my questions may sound simple.
I implemented an MDB( serving as a Consumer ) using JDeveloper 11.1.7 and built a JAR file using deployment functionality. Now I need to deploy it to WebLogic 10.3 app server. I have several questions:
1) Should I deploy it as a library or as an application?
2) After I successfully deploy and it's in the "RUNNING" mode I assume it should be listening to the particular Queue I specified as a Resource in my MDB implementation. Is that correct?
3) When implementing an MDB all the examples only specify the "destination" but not the "ConnectionFactory". How does it know where to connect to?
Should I deploy it as a library or as an application?
Deploy as an application since the MDB will likely contain business logic specific to the app.
After I successfully deploy and it's in the "RUNNING" mode I assume it
should be listening to the particular Queue I specified as a Resource
in my MDB implementation. Is that correct?
Yes, if your JMS provider is local, specify the name bound in the local JNDI tree for the destination using destination-jndi-name.
When implementing an MDB all the examples only specify the
"destination" but not the "ConnectionFactory". How does it know where
to connect to?
If the MDB is consuming messages from the local WebLogic JMS provider, the container manages configuration for the connections and sessions automatically, so don't set provider-url, initial-context-factory, or connection-factory-jndi-name, unless you have a custom factory to use.
Refer to WebLogic 10.3 documentation for details:

Configuring JBoss EPA 6.1 with IBM MQ

I am developing a service for JMS messaging using IBM WMQ version 7.5 as Message oriented middleware. I am in a dilemma. The IBM specification says to use WebSphere MQ JMS API in JAVA EE environment. My sender and receivers will be in remote JBoss deployments. IBM provides a resource adapter to connect via JCA. This connection requires static administration of components such as Queue managers, queue channels, queue names.
Is JCA the best I can do ? Is there any other way where I can dynamically create the queues provided that I know other configuration details ? There will be multiple applications using this setup running on their own servers. If I use JCA, all have to make their own configurations. Can I make dynamic configurations ?
Typically within the application server environment resources would be created in some JNDI context. These would be Connection Factories and Destinations.
Depending on the app server, it may be possible to share this configuration across a network of individual servers. So typically there would be some set of static definitions.
However within say a servlet the MQConnectionFactory can be dynamically created.
In all cases the backing WMQ Resources do need to exist; though it is possible to send administrative command messages to WMQ to create queues and do other admin. The only exception is topics, accessing a topic string brings it into existence. Though this has default security properties that you might not want.

configure jndi.xml in serviceMix to work with MQseries

My j2EE app is currently running on ServiceMix. Now i want to add JMS to my app. The application should able to send/receive the JMS message to/from the queue that stays on MQSeries.
mq.hostname=10.3.6.19
mq.channel=CHANNEL
mq.queueManager=QManager
mq.port=1422
What i would like to do is:
1. Create a jndi.xml file and do configuration for jms stuff.
2. my app will initialize the context, look up jndi name, and create a connection, queueManager, queue. .etc
3. Develop send and receive methods.
My question is:
Can you tell me how to do 1st and 2nd steps.
(the script inside ServiceMix's jndi is diffrent with tomcat's
jndi and others.
ServiceMix using Spring based JNDI provider.
http://servicemix.apache.org/jndi-configuration.html)
I just ran into something similar with Weblogic. The following link uses spring-dm to integrate with websphere. It also takes it to the next logical step and adds camel to the mix.
http://lowry-techie.blogspot.com/2010/11/camel-integration-with-websphere-mq.html
Without using Spring-dm, you may run into classloader issues when trying to load the InitialContextFactory from the websphere jar (this is an issue I had with the Weblogic jar)

Resources