Skip to main content

glassfish v3 jms

7 replies [Last post]
cassionoronha
Offline
Joined: 2010-10-07
Points: 0

What do i have to change in this code, if my Queue is on another Host(ip: 10.73.0.9)?

My english is not good, but i don't find the solution in web.

Thanks.
Cassio.

try {
jndiContext = new InitialContext();
System.out.println("CONEXAO");
connectionFactory = (ConnectionFactory)jndiContext.lookup("jms/CF");
queue = (Queue)jndiContext.lookup("jms/Queue");
connection = connectionFactory.createConnection();
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
messageProducer = session.createProducer(queue);
// object that will send
Quotes quote = new Quotes("^BVSP", new Date(), counter++, 0, 0, 0, (int)(Math.random() * 100));
msg = session.createObjectMessage(quote);
msg.setStringProperty("symbol", quote.symbol);
msg.setFloatProperty("volume", quote.volume);
// send object
messageProducer.send(msg);
connection.close();
} catch (NamingException e) {
Logger.getLogger(JMSEnvio.class.getName()).log(Level.SEVERE, null, e);
}
catch (JMSException e) {
Logger.getLogger(JMSEnvio.class.getName()).log(Level.SEVERE, null, e);
} finally {
System.out.println("ENDED.");
//System.out.println("PROVIDER_URL: " + properties.get(Context.PROVIDER_URL));
if (connection != null) connection.close();
}

Message was edited by: cassionoronha

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Dominik Dorn

nothing.
you have to configure your connectionFactory
with the admin console and specify that it's on a remote host.

On Thu, Oct 7, 2010 at 10:04 PM, wrote:
> What do i have to change in this code, if my Quote is on another Host(ip: 10.73.0.9)?
>
> My english is not good, but i don't find the solution in web.
>
> Thanks.
> Cassio.
>
>
>
> try {
>            jndiContext = new InitialContext();
>            System.out.println("CONEXAO");
>            connectionFactory = (ConnectionFactory)jndiContext.lookup("jms/CF");
>            queue = (Queue)jndiContext.lookup("jms/Queue");
>            connection = connectionFactory.createConnection();
>            session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
>            messageProducer = session.createProducer(queue);
>            // object that will send
>            Quotes quote = new Quotes("^BVSP", new Date(), counter++, 0, 0, 0, (int)(Math.random() * 100));
>            msg = session.createObjectMessage(quote);
>            msg.setStringProperty("symbol", quote.symbol);
>            msg.setFloatProperty("volume", quote.volume);
>                        // send object
>            messageProducer.send(msg);
>            connection.close();
> } catch (NamingException e) {
>            Logger.getLogger(JMSEnvio.class.getName()).log(Level.SEVERE, null, e);
> }
>        catch (JMSException e) {
>            Logger.getLogger(JMSEnvio.class.getName()).log(Level.SEVERE, null, e);
> } finally {
>            System.out.println("ENDED.");
>            //System.out.println("PROVIDER_URL: " + properties.get(Context.PROVIDER_URL));
>            if (connection != null) connection.close();
> }
> [Message sent by forum member 'cassionoronha']
>
> http://forums.java.net/jive/thread.jspa?messageID=484573
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
> For additional commands, e-mail: users-help@glassfish.dev.java.net
>
>

--
Dominik Dorn
http://dominikdorn.com
http://twitter.com/domdorn

Tausche Deine Lernunterlagen auf http://www.studyguru.eu !

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: users-help@glassfish.dev.java.net

serge_poberezhnik
Offline
Joined: 2008-10-24
Points: 0

Is all right about ConnectionFactory, wich supports property AddressList to redirect it to remote host. And what about Queue admin object? How to redirect this one? It doesn't support AddressList property. And jndiContext.lookup("jms/Queue") will return local admin object. Therefore all messages sent to such queue will procceed to local one.

nigeldeakin
Offline
Joined: 2007-10-12
Points: 0

When you send messages to a queue, they will be saved on the MQ broker that your JMS connection is connected to. So you only need to configure the connection factory, not the queue itself.

Nigel

serge_poberezhnik
Offline
Joined: 2008-10-24
Points: 0

Thanks for your answer, Nigel. It works

cassionoronha
Offline
Joined: 2010-10-07
Points: 0

I configure a ConnectionFactory in Glassfish Console Admin. I put the Property 'AdressList' with value='10.73.3.152:3700' and when i Ping is returned the message:

[b][C4003]: Error occurred on connection creation [10.73.3.152:3700]. - cause: java.lang.NumberFormatException: For input string: " [i]large blank string[/i] "[/b]

The server.log exception:

[b]
[#|2010-10-19T15:18:25.851-0300|SEVERE|glassfish3.0.1|javax.resourceadapter.mqjmsra.outbound.connection|_ThreadID=34;_ThreadName=Thread-1;|MQJMSRA_MC4001: constructor:Aborting:JMSException on createConnection=[C4003]: Error occurred on connection creation [10.73.3.152:3700]. - cause: java.lang.NumberFormatException: For input string: "
[#|2010-10-19T15:18:25.856-0300|SEVERE|glassfish3.0.1|javax.enterprise.system.std.com.sun.enterprise.v3.services.impl|_ThreadID=34;_ThreadName=Thread-1;|com.sun.messaging.jms.JMSException: [C4003]: Error occurred on connection creation [10.73.3.152:3700]. - cause: java.lang.NumberFormatException: For input string: "
at com.sun.messaging.jmq.jmsclient.ExceptionHandler.throwConnectionException(ExceptionHandler.java:274)
at com.sun.messaging.jmq.jmsclient.ExceptionHandler.handleConnectException(ExceptionHandler.java:220)
at com.sun.messaging.jmq.jmsclient.PortMapperClient.readBrokerPorts(PortMapperClient.java:241)
at com.sun.messaging.jmq.jmsclient.PortMapperClient.init(PortMapperClient.java:150)
at com.sun.messaging.jmq.jmsclient.PortMapperClient.(PortMapperClient.java:92)
at com.sun.messaging.jmq.jmsclient.protocol.tcp.TCPConnectionHandler.(TCPConnectionHandler.java:165)
at com.sun.messaging.jmq.jmsclient.protocol.tcp.TCPStreamHandler.openConnection(TCPStreamHandler.java:135)
at com.sun.messaging.jmq.jmsclient.ConnectionInitiator.createConnection(ConnectionInitiator.java:778)
at com.sun.messaging.jmq.jmsclient.ConnectionInitiator.createConnectionNew(ConnectionInitiator.java:254)
at com.sun.messaging.jmq.jmsclient.ConnectionInitiator.createConnection(ConnectionInitiator.java:208)
at com.sun.messaging.jmq.jmsclient.ConnectionInitiator.createConnection(ConnectionInitiator.java:158)
at com.sun.messaging.jmq.jmsclient.ProtocolHandler.init(ProtocolHandler.java:836)
at com.sun.messaging.jmq.jmsclient.ProtocolHandler.(ProtocolHandler.java:1528)
at com.sun.messaging.jmq.jmsclient.ConnectionImpl.openConnection(ConnectionImpl.java:2366)
at com.sun.messaging.jmq.jmsclient.ConnectionImpl.init(ConnectionImpl.java:1047)
at com.sun.messaging.jmq.jmsclient.ConnectionImpl.(ConnectionImpl.java:433)
at com.sun.messaging.jmq.jmsclient.UnifiedConnectionImpl.(UnifiedConnectionImpl.java:60)
at com.sun.messaging.jmq.jmsclient.XAConnectionImpl.(XAConnectionImpl.java:58)
at com.sun.messaging.XAConnectionFactory.createXAConnection(XAConnectionFactory.java:91)
at com.sun.messaging.jms.ra.ManagedConnection.(ManagedConnection.java:194)
at com.sun.messaging.jms.ra.ManagedConnectionFactory.createManagedConnection(ManagedConnectionFactory.java:223)
at com.sun.enterprise.connectors.service.ConnectorConnectionPoolAdminServiceImpl.getManagedConnection(ConnectorConnectionPoolAdminServiceImpl.java:517)
at com.sun.enterprise.connectors.service.ConnectorConnectionPoolAdminServiceImpl.getUnpooledConnection(ConnectorConnectionPoolAdminServiceImpl.java:627)
at com.sun.enterprise.connectors.service.ConnectorConnectionPoolAdminServiceImpl.testConnectionPool(ConnectorConnectionPoolAdminServiceImpl.java:439)
at com.sun.enterprise.connectors.ConnectorRuntime.pingConnectionPool(ConnectorRuntime.java:910)
at org.glassfish.admin.amx.impl.ext.ConnectorRuntimeAPIProviderImpl.pingJDBCConnectionPool(ConnectorRuntimeAPIProviderImpl.java:570)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.glassfish.admin.amx.impl.mbean.AMXImplBase.invoke(AMXImplBase.java:1038)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:836)
at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:761)
at javax.management.MBeanServerInvocationHandler.invoke(MBeanServerInvocationHandler.java:288)
at org.glassfish.admin.amx.util.jmx.MBeanProxyHandler.invoke(MBeanProxyHandler.java:453)
at org.glassfish.admin.amx.core.proxy.AMXProxyHandler._invoke(AMXProxyHandler.java:822)
at org.glassfish.admin.amx.core.proxy.AMXProxyHandler.invoke(AMXProxyHandler.java:526)
at $Proxy162.pingJDBCConnectionPool(Unknown Source)
at org.glassfish.admingui.common.handlers.JdbcTempHandler.pingJdbcConnectionPool(JdbcTempHandler.java:99)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.sun.jsftemplating.layout.descriptors.handler.Handler.invoke(Handler.java:442)
at com.sun.jsftemplating.layout.descriptors.LayoutElementBase.dispatchHandlers(LayoutElementBase.java:420)
at com.sun.jsftemplating.layout.descriptors.LayoutElementBase.dispatchHandlers(LayoutElementBase.java:394)
at com.sun.jsftemplating.layout.event.CommandActionListener.invokeCommandHandlers(CommandActionListener.java:150)
at com.sun.jsftemplating.layout.event.CommandActionListener.processAction(CommandActionListener.java:98)
at javax.faces.event.ActionEvent.processListener(ActionEvent.java:88)
at javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:772)
at javax.faces.component.UICommand.broadcast(UICommand.java:300)
at com.sun.webui.jsf.component.WebuiCommand.broadcast(WebuiCommand.java:166)
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:775)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1267)
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:82)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:312)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1523)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:343)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215)
at com.sun.webui.jsf.util.UploadFilter.doFilter(UploadFilter.java:233)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215)
at org.apache.catalina.core.StandardWrapperValve.invoke(Stan|#]

[#|2010-10-19T15:18:25.953-0300|SEVERE|glassfish3.0.1|javax.enterprise.system.std.com.sun.enterprise.v3.services.impl|_ThreadID=34;_ThreadName=Thread-1;|dardWrapperValve.java:277)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:188)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:641)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:97)
at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:85)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:185)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:325)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:226)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:239)
at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:791)
at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:693)
at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:954)
at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:170)
at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:135)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:102)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:88)
at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76)
at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:53)
at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:57)
at com.sun.grizzly.ContextTask.run(ContextTask.java:69)
at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:330)
at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:309)
at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.NumberFormatException: For input string: "
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
at java.lang.Integer.parseInt(Integer.java:449)
at java.lang.Integer.parseInt(Integer.java:499)
at com.sun.messaging.jmq.io.PortMapperTable.read(PortMapperTable.java:271)
at com.sun.messaging.jmq.jmsclient.PortMapperClient.readBrokerPorts(PortMapperClient.java:235)
... 84 more
[/b]

Somebody knows how to fix this?

Thanks

serge_poberezhnik
Offline
Joined: 2008-10-24
Points: 0

In property AddressList put not an Corba broker remote address, but an OpenMQ remote broker address, like this (port 7676 by default)
AdressList=mq://10.73.3.152:7676

And one more thing. In remote glassfish v3.0.1 domain change host in default_JMS_host settings (in console - Configuration\Java Message Service\JMS Hosts) from 0.0.0.0 or localhost by default to your real server IP, for example 10.73.3.152.
After that restart both domains - local and remote. And it should works.

cassionoronha
Offline
Joined: 2010-10-07
Points: 0

Thank you so much.
I have success here. Thank you!
I was searching for this solution since begginning of October. Thank you again!