I am trying to use the archetype cdi-camel-mq-archetype to test out an application running on OpenShift in its own namespace. I want this application to use a message broker that is residing in a different namespace on the same OpenShift cluster. But when I am running the application on OpenShift I see the following error in the POD's logs:
java.lang.RuntimeException: Failed to process @Factory annotated method: create on bean: com.demo.mqdemotest.ActiveMQComponentFactory. Failed to lookup bean of type: class org.apache.activemq.ActiveMQConnectionFactory for service: broker-tcp.
Caused by: java.lang.RuntimeException: Failed to process @Factory annotated method: create on bean: com.demo.mqdemotest.mq.ActiveMQConfigurer. Failed to lookup service broker-tcp.
Caused by: java.lang.IllegalArgumentException: No kubernetes service could be found for name: broker-tcp in namespace: null
Is there a way to inject the namespace that my broker lives in to my application (as I do not see a way to do this in the fabric8 cdi documentation)? If not how could I get this to work as expected?
You have two options. Depending on your setup:
In the future through linking support you will be able to directly provide a service from one project to another.
If you have a flat network in your OpenShift installation and no namespace segregation, the issue in your case might be how you reference your services between projects.
If you are in camel-mq
project, you can use the services from mq-demo
project using the url:
<service>.mq-demo.svc.cluster.local:<port>
To get services in your mq-demo
run:
oc get svc -n mq-demo
More on networking can be found here: OpenShift Origin: Networking
Next possibility - based on the exception message broker-tcp in namespace: null
. Maybe you should specify the namespace in which the broker-tcp
service exists.