Camel https web service consumer - jboss

I am trying to build a camel https web service consumer and I am not successful in calling this web service. This web service is currently using API-Key authentication and I have the API key. Below is my code that I have tried. Can someone give me some direction as to what I need to do to be able to do api key authentication with this remote web service?
<?xml version="1.0" encoding="UTF-8"?>
<!-- Configures the Camel Context-->
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:camel="http://camel.apache.org/schema/spring"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-http.xsd">
<camelContext xmlns="http://camel.apache.org/schema/spring">
<route>
<from uri="direct:start"/>
<setHeader headerName="CamelHttpMethod">
<constant>POST</constant>
</setHeader>
<to uri="https://api.url.com/api/v3.1/site/query/site/<apikeyhere>"/>
<log message="Message Recieved"/>
<to uri="file:target/messages/message"/>
</route>
</camelContext>
</beans>

All I needed here was the following code:
<to uri="https://api.url.com/api/v3.1/site/query/site/?apiKeyabcd1234"/>
And then I was able to get the data flowing.

Related

Exception communicating with endpoint

I am implementing an application which would be exposed using RESTful web service. This application would firstly consume a RESTful web service to get the JSON file and would return this JSON file to the requestor (application which would consume my service). I am facing issues consuming the web service.
ERROR:
org.apache.camel.component.restlet.RestletOperationException: Restlet operation failed invoking https:// <--url-->
with statusCode: 1001 /n responseBody:HTTPS/1.1 - Communication Error (1001) -
The connector failed to complete the communication with the server
at org.apache.camel.component.restlet.RestletProducer.populateRestletProducerException(RestletProducer.java:233)
CODE:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
<camelContext id="camelcontext" xmlns="http://camel.apache.org/schema/spring">
<restConfiguration component="restlet" port="9091"/>
<rest path="/say">
<get uri="/hello" consumes="application/json" produces="application/json">
<to uri="direct:hello" />
</get>
</rest>
<route>
<from uri="direct:hello"/>
<to uri="restlet:https:// <--URL--> ?restletMethod=POST" />
</route>
</camelContext>
</beans>
Maby incoming request has additional headers, for example as in this issue Apache camel jetty RestletOperationException on invoking request 1001 when mocked restlet endpoint ("org.restlet.http.headers"). You can check and remove unnecessary headers from the request. Also, error may occur while the response by the same reason, check our service for set headers.

Camel REST - Path based routing

I have to develop a Camel REST route with path-based routing.
The scenario is as follows: we have a business partner which provided a REST web service for displaying documents. The REST web service is deployed on 3 different servers, depending on the geographic location.
So we basically have 3 server like these:
http://north.acme.com/flowdocv2/rest/repository/attachment/{id}/findById
http://center.acme.com/flowdocv2/rest/repository/attachment/{id}/findById
http://south.acme.com/flowdocv2/rest/repository/attachment/{id}/findById
My aim is to develop a single Camel route to map these server, accepting the name of the server in the path. Something like this:
http://my.camel.com/center/repository/attachment/{id}/findById
http://my.camel.com/north/repository/attachment/{id}/findById
http://my.camel.com/south/repository/attachment/{id}/findById
My (simplified and not working) blueprint.xml:
<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0"
xmlns:cxf="http://camel.apache.org/schema/blueprint/cxf"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0
https://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
http://camel.apache.org/schema/blueprint http://camel.apache.org/schema/blueprint/camel-blueprint.xsd">
<cm:property-placeholder persistent-id="my.config.file"/>
<reference id="sharedNettyHttpServer" interface="org.apache.camel.component.netty4.http.NettySharedHttpServer"/>
<camelContext id="my_context" xmlns="http://camel.apache.org/schema/blueprint">
<restConfiguration component="netty4-http">
<endpointProperty key="nettySharedHttpServer" value="#sharedNettyHttpServer"/>
</restConfiguration>
<rest path="/center/repository">
<get uri="/attachment/{attachmentId}/findById">
<route streamCache="true" trace="true">
<to uri="http://center.acme.com/flowdocv2/rest?bridgeEndpoint=true"/>
</route>
</get>
</rest>
<rest path="/north/repository">
<get uri="/attachment/{attachmentId}/findById">
<route streamCache="true" trace="true">
<to uri="http://north.acme.com/flowdocv2/rest?bridgeEndpoint=true"/>
</route>
</get>
</rest>
</camelContext>
</blueprint>
The problem is that I don't know how to remove /center, /north or /south from the path, so the header is forwared to the destination service, which doesn't know how to deal with it.
Invoking:
http://my.camel.com/center/repository/attachment/{id}/findById
results in the following URL being invoked on the destination server:
http://center.acme.com/flowdocv2/rest/center/repository/attachment/{id}/findById
How to get rid of center? I don't want to deploy 3 camel routes on different ports.
Thank you
I think it is actually a bit easier. As long as you do not hang onto netty and you are using Camel 2.11+ you can use camel-urlrewrite
Basically, you define a single rewrite rule in a configuration and add this to your route bundle.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE urlrewrite PUBLIC "-//tuckey.org//DTD UrlRewrite 4.0//EN"
"http://www.tuckey.org/res/dtds/urlrewrite4.0.dtd">
<urlrewrite>
<rule>
<name>Generic Proxy</name>
<note>
This rule completely rewrites the url to call.
Basically, in Camel's "to", you could write whatever you want
</note>
<from>^/(.*?)/(.*)</from>
<to>http://$1.acme.com/flowdocv2/rest/$2</to>
</rule>
</urlrewrite>
Now, you can utilize a rather simple route:
<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0" xmlns:cxf="http://camel.apache.org/schema/blueprint/cxf" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0
https://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
http://camel.apache.org/schema/blueprint http://camel.apache.org/schema/blueprint/camel-blueprint.xsd">
<bean id="myRewrite" class="org.apache.camel.component.urlrewrite.HttpUrlRewrite">
<property name="configFile" value="class/path/to/proxyrewrite.xml" />
</bean>
<camelContext id="my_context" xmlns="http://camel.apache.org/schema/blueprint">
<route id="proxyRoute">
<from uri="jetty:http://localhost:9090/proxy" />
<to uri="jetty:http://somewhere/myapp2?bridgeEndpoint=true&throwExceptionOnFailure=false&urlRewrite=#myRewrite" />
</route>
</camelContext>
</blueprint>
However, netty is not supported, so I chose the next best thing.
When you call http://localhost:9090/proxy/north/foo, the rewrite will actually change the url to call to http://north.acme.com/flowdoc2/rest/foo.
There are a few caveats with this. First, you have to use one of the supported components for UrlRewrite. Second, it seems that you have to have the rewrite config file in you classpath - so no blueprint-only route. Third: I did not test it, but I think you get the gist. I make this a community wiki answer, so that others, more capable than me, can expand on this answer.

Expose a Pass-Through proxy with Jboss Fuse

I am an newbie with JBoss Fuse and I would like to expose a Pass-Through proxy with Jboss Fuse.
I am using JBoss EAP 6.4 in which I have installed the JBoss Fuse 6.3.
Also I have downloaded Red Hat JBoss Developer Studio 10.4.0.GA and I have started some new Fuse Integration Projects in Spring DSL.
The main idea is to create a Fuse which will work as a front layer of a SOAP Web Service in order to use the throttling and some others features of Fuse.
Could you please advise me, if this is feasible?
Thanks you in advance!
EDIT:
I was looking something like the following:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
<camelContext id="_camelContext1" xmlns="http://camel.apache.org/schema/spring">
<route id="_route1">
<from id="_from1" uri="cxf:beanId:address"/>
<to id="_to1" uri="cxf:beanId:address"/>
</route>
</camelContext>
</beans>
But I need to implement the SOAP (CXF) Web Service which will be stand before the Camel route. Am I wrong?
You can try experimenting with Apache Camel.
Listen from some port and route incoming requests to the SOAP web service, here's an example:
<camelContext xmlns="http://camel.apache.org/schema/blueprint" id="PassThroughProxy" >
<route id="ProxyRoute">
<from uri="jetty:http://0.0.0.0:8080?matchOnUriPrefix=true"/>
<log message="Incoming message - headers: ${headers}" />
<log message="Incoming message - payload: ${body}" />
<to uri="bean:someProcessorHere" />
<to uri="http://soap.somewhere.net:80?bridgeEndpoint=true&throwExceptionOnFailure=false"/>
</route>
</camelContext>
Use Jetty component as input, process HTTP headers and/or body using Camel (processor, routes, ...), then use HTTP component as a client to the real web service.
You can configure SSL support, custom headers handling and so on.
If I were you, I'd use some dedicated piece of software to do this job, like Nginx.

Apache Camel ResolveEndpointFailedException - Failed to resolve endpoint

I was trying to access an outside service built in ASP.net using Jboss fuse and Camel. I am new to this integration thing using Fuse. When I try to run the following camel-context.xml
<?xml version="1.0" encoding="UTF-8"?>
<!--
JBoss, Home of Professional Open Source
Copyright 2014, Red Hat, Inc. and/or its affiliates, and individual
contributors by the #authors tag. See the copyright.txt in the
distribution for a full listing of individual contributors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- Configures the Camel Context-->
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:cxf="http://camel.apache.org/schema/cxf"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd http://camel.apache.org/schema/cxf http://camel.apache.org/schema/cxf/camel-cxf.xsd ">
<cxf:cxfEndpoint address="/report" id="reportEndpoint" serviceClass="com.mycompany.camel.cxf.code.first.spring.incident.IncidentService"/>
<cxf:cxfEndpoint
address="http://www.webservicex.net/CurrencyConvertor.asmx"
endpointName="c:SOAPOverHTTP" id="wsdlEndpoint"
serviceName="c:CurrencyConvertor" xmlns:s="http://www.webserviceX.NET"/>
<bean
class="com.mycompany.camel.cxf.code.first.spring.incident.ReportIncidentProcessor" id="reportIncidentProcessor"/>
<bean
class="com.mycompany.camel.cxf.code.first.spring.incident.StatusIncidentProcessor" id="statusIncidentProcessor"/>
<camelContext id="camelContext-c1100b64-c8cb-4fa6-b382-5eea0e303c95" xmlns="http://camel.apache.org/schema/spring">
<route id="asmx_route1">
<from id="_from1" uri="file:src/data/auth?noop=true"/>
<log id="_log1" message="${body}"/>
<to id="_to3" uri="cxf:bean:wsdlEndpoint?dataFormat=MESSAGE"/>
<log id="_log2" message="${body}"/>
</route>
<route id="cxf">
<!-- route starts from the cxf webservice in POJO mode -->
<from id="reportEndpointListener" uri="cxf:bean:reportEndpoint"/>
<recipientList id="dispatchToCorrectRoute">
<simple>direct:${header.operationName}</simple>
</recipientList>
</route>
<route id="report">
<from id="reportIncidentStarter" uri="direct:reportIncident"/>
<log id="logReportIncident" message="reportIncident Call"/>
<process id="reportIncidentProcess" ref="reportIncidentProcessor"/>
<to id="_to1" uri="log:output"/>
</route>
<route id="status">
<from id="statusIncidentStarter" uri="direct:statusIncident"/>
<log id="logStatusIncident" message="statusIncident Call"/>
<process id="statusIncidentProcess" ref="statusIncidentProcessor"/>
<to id="_to2" uri="log:output"/>
</route>
</camelContext>
</beans>
I get this error in the fuse log,
org.apache.camel.ResolveEndpointFailedException: Failed to resolve endpoint: direct: due to: Expected scheme-specific part at index 7: direct:
at org.apache.camel.impl.DefaultCamelContext.normalizeEndpointUri(DefaultCamelContext.java:661)[232:org.apache.camel.camel-core:2.17.0.redhat-630187]
at org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:543)[232:org.apache.camel.camel-core:2.17.0.redhat-630187]
at org.apache.camel.util.CamelContextHelper.getMandatoryEndpoint(CamelContextHelper.java:79)[232:org.apache.camel.camel-core:2.17.0.redhat-630187]
at org.apache.camel.util.ExchangeHelper.resolveEndpoint(ExchangeHelper.java:89)[232:org.apache.camel.camel-core:2.17.0.redhat-630187]
at org.apache.camel.processor.RecipientListProcessor.resolveEndpoint(RecipientListProcessor.java:254)[232:org.apache.camel.camel-core:2.17.0.redhat-630187]
at org.apache.camel.processor.RecipientListProcessor.createProcessorExchangePairs(RecipientListProcessor.java:193)[232:org.apache.camel.camel-core:2.17.0.redhat-630187]
at org.apache.camel.processor.MulticastProcessor.process(MulticastProcessor.java:231)[232:org.apache.camel.camel-core:2.17.0.redhat-630187]
at org.apache.camel.processor.RecipientList.sendToRecipientList(RecipientList.java:170)[232:org.apache.camel.camel-core:2.17.0.redhat-630187]
at org.apache.camel.processor.RecipientList.process(RecipientList.java:131)[232:org.apache.camel.camel-core:2.17.0.redhat-630187]
at org.apache.camel.processor.Pipeline.process(Pipeline.java:121)[232:org.apache.camel.camel-core:2.17.0.redhat-630187]
at org.apache.camel.processor.Pipeline.process(Pipeline.java:83)[232:org.apache.camel.camel-core:2.17.0.redhat-630187]
at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:77)[232:org.apache.camel.camel-core:2.17.0.redhat-630187]
at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:468)[232:org.apache.camel.camel-core:2.17.0.redhat-630187]
at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:196)[232:org.apache.camel.camel-core:2.17.0.redhat-630187]
at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:196)[232:org.apache.camel.camel-core:2.17.0.redhat-630187]
at org.apache.camel.component.cxf.CxfConsumer$CxfConsumerInvoker.asyncInvoke(CxfConsumer.java:154)[241:org.apache.camel.camel-cxf:2.17.0.redhat-630187]
at org.apache.camel.component.cxf.CxfConsumer$CxfConsumerInvoker.invoke(CxfConsumer.java:133)[241:org.apache.camel.camel-cxf:2.17.0.redhat-630187]
at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:59)[74:org.apache.cxf.cxf-core:3.1.5.redhat-630187]
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)[:1.8.0_121]
at java.util.concurrent.FutureTask.run(Unknown Source)[:1.8.0_121]
at org.apache.cxf.interceptor.ServiceInvokerInterceptor$2.run(ServiceInvokerInterceptor.java:126)[74:org.apache.cxf.cxf-core:3.1.5.redhat-630187]
at org.apache.cxf.workqueue.SynchronousExecutor.execute(SynchronousExecutor.java:37)[74:org.apache.cxf.cxf-core:3.1.5.redhat-630187]
at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:131)[74:org.apache.cxf.cxf-core:3.1.5.redhat-630187]
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308)[74:org.apache.cxf.cxf-core:3.1.5.redhat-630187]
at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)[74:org.apache.cxf.cxf-core:3.1.5.redhat-630187]
at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:254)[118:org.apache.cxf.cxf-rt-transports-http:3.1.5.redhat-630187]
at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:234)[118:org.apache.cxf.cxf-rt-transports-http:3.1.5.redhat-630187]
at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:208)[118:org.apache.cxf.cxf-rt-transports-http:3.1.5.redhat-630187]
at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:160)[118:org.apache.cxf.cxf-rt-transports-http:3.1.5.redhat-630187]
at org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:180)[118:org.apache.cxf.cxf-rt-transports-http:3.1.5.redhat-630187]
at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:299)[118:org.apache.cxf.cxf-rt-transports-http:3.1.5.redhat-630187]
at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doGet(AbstractHTTPServlet.java:223)[118:org.apache.cxf.cxf-rt-transports-http:3.1.5.redhat-630187]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:687)[81:javax.servlet-api:3.1.0]
at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:274)[118:org.apache.cxf.cxf-rt-transports-http:3.1.5.redhat-630187]
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:812)[94:org.eclipse.jetty.servlet:9.2.19.v20160908]
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:587)[94:org.eclipse.jetty.servlet:9.2.19.v20160908]
at org.ops4j.pax.web.service.jetty.internal.HttpServiceServletHandler.doHandle(HttpServiceServletHandler.java:71)[117:org.ops4j.pax.web.pax-web-jetty:4.3.0]
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)[93:org.eclipse.jetty.server:9.2.19.v20160908]
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:577)[92:org.eclipse.jetty.security:9.2.19.v20160908]
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:223)[93:org.eclipse.jetty.server:9.2.19.v20160908]
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127)[93:org.eclipse.jetty.server:9.2.19.v20160908]
at org.ops4j.pax.web.service.jetty.internal.HttpServiceContext.doHandle(HttpServiceContext.java:287)[117:org.ops4j.pax.web.pax-web-jetty:4.3.0]
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515)[94:org.eclipse.jetty.servlet:9.2.19.v20160908]
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)[93:org.eclipse.jetty.server:9.2.19.v20160908]
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061)[93:org.eclipse.jetty.server:9.2.19.v20160908]
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)[93:org.eclipse.jetty.server:9.2.19.v20160908]
at org.ops4j.pax.web.service.jetty.internal.JettyServerHandlerCollection.handle(JettyServerHandlerCollection.java:80)[117:org.ops4j.pax.web.pax-web-jetty:4.3.0]
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)[93:org.eclipse.jetty.server:9.2.19.v20160908]
at org.eclipse.jetty.server.Server.handle(Server.java:499)[93:org.eclipse.jetty.server:9.2.19.v20160908]
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:311)[93:org.eclipse.jetty.server:9.2.19.v20160908]
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:257)[93:org.eclipse.jetty.server:9.2.19.v20160908]
at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:544)[86:org.eclipse.jetty.io:9.2.19.v20160908]
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635)[96:org.eclipse.jetty.util:9.2.19.v20160908]
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555)[96:org.eclipse.jetty.util:9.2.19.v20160908]
at java.lang.Thread.run(Unknown Source)[:1.8.0_121]
Caused by: java.net.URISyntaxException: Expected scheme-specific part at index 7: direct:
at java.net.URI$Parser.fail(Unknown Source)[:1.8.0_121]
at java.net.URI$Parser.failExpecting(Unknown Source)[:1.8.0_121]
at java.net.URI$Parser.parse(Unknown Source)[:1.8.0_121]
at java.net.URI.<init>(Unknown Source)[:1.8.0_121]
at org.apache.camel.util.URISupport.normalizeUri(URISupport.java:534)[232:org.apache.camel.camel-core:2.17.0.redhat-630187]
at org.apache.camel.impl.DefaultCamelContext.normalizeEndpointUri(DefaultCamelContext.java:659)[232:org.apache.camel.camel-core:2.17.0.redhat-630187]
... 54 more
Please ask if you need anymore sources I used so that I can give you a clear understanding. Thanks in advance.

How to expose activemq JMX MBeans via jboss web based jmx-console?

I have been trying to configure activemq such that the broker MBeans are available in jboss's web based jmx-console available at http://localhost:8080/jmx-console.
I have tried
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:util="http://www.springframework.org/schema/util" xmlns:amq="http://activemq.apache.org/schema/core"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.1.xsd
http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq- core.xsd">
<beans>
<broker xmlns="http://activemq.apache.org/schema/core" useJmx="true"
useShutdownHook="false">
<!-- Use the following to configure how ActiveMQ is exposed in JMX -->
<managementContext>
<!-- <managementContext createConnector="false" /> -->
<managementContext>
<MBeanServer>
<bean class="org.jboss.mx.util.MBeanServerLocator"
factory-method="locateJBoss" xmlns="" />
</MBeanServer>
</managementContext>
</managementContext>
</broker>
</beans>
When I deploy the war the piece of xml gives error
cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'bean'.
Any idea how to make activemq MBeans integrate with jboss web based jmx-console?
Default settings with just createConnector=false won't work for me because jboss is configured to not use 1099 RMI port. LocateJboss factory-method call on org.jboss.mx.util.MBeanServerLocator is the only way (I know of) to get jboss MBeanServer handle.
According to the spring JMX doc, you could try something like this :
<bean id="exporter" class="org.springframework.jmx.export.MBeanExporter">
<property name="server">
<bean id="mBeanServerLocator" class="org.jboss.mx.util.MBeanServerLocator"
factory-method="locateJBoss" />
</property>
</bean>
<broker xmlns="http://activemq.apache.org/schema/core" useJmx="true"
useShutdownHook="false">
<!-- Use the following to configure how ActiveMQ is exposed in JMX -->
<managementContext>
<managementContext MBeanServer="exporter"/>
<!-- I am not sure what MBeanServer attribute is waiting for (a ref, an id, something else ...)-->
</managementContext>
</broker>