<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">

<div>
        <table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                <tbody>
                        <tr>

                                <td>

                                        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                                                <tbody>
                                                        <tr>
                                                                <td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
                                                                        <h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
                                                                        <!-- To have a header image/logo replace the name below with your img tag -->
                                                                        <!-- Email clients will render the images when the message is read so any image -->
                                                                        <!-- must be made available on a public server, so that all recipients can load the image. -->
                                                                        <a href="http://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">JBoss Community</a></h1>
                                                                </td>

                                                        </tr>
                                                        <tr>
                                                                <td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px;  -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
    JBoss Settings for MDB Client ?
</h3>
<span style="margin-bottom: 10px;">
    created by <a href="http://community.jboss.org/people/shptlucky">shptlucky</a> in <i>JBoss Messaging</i> - <a href="http://community.jboss.org/message/603174#603174">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">

<div class="jive-rendered-content"><p>I have made message driven bean. </p><p>I have made a producer class.</p><p>I am using Netbeans</p><p>Producer Class is sending message to local host and i am recieving it.</p><p>but i am not getting settings to be done for remote connection.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>I am striving for last three weeks on it. Please anyone help and tell me what settings is required on client side or server for Remote JMS message retrieving. Code is here under:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><strong>For Sending</strong></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>package com;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>import java.util.Hashtable;</p><p>import javax.naming.Context;</p><p>import javax.naming.InitialContext;</p><p>import javax.naming.NamingException;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>import javax.jms.TopicConnectionFactory;</p><p>import javax.jms.TopicConnection;</p><p>import javax.jms.TopicSession;</p><p>import javax.jms.TopicPublisher;</p><p>import javax.jms.Topic;</p><p>import javax.jms.TextMessage;</p><p>import javax.jms.Session;</p><p>import javax.jms.JMSException;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>/**</p><p> * &lt;p&gt;Simple JMS client, publish text messages to testTopic Topic.</p><p> * &lt;/p&gt;</p><p> *</p><p> * &lt;p&gt;&lt;b&gt;NOTE&lt;/b&gt;This code is a showcase only. It may not provide</p><p> * a stable production example.&lt;/p&gt;</p><p> * @author Peter Antman</p><p> * @version $Revision: 3.1 $</p><p> */</p><p>public class NewClass {</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160; /**</p><p>&#160;&#160;&#160;&#160; * Topic connection, hold on to this so you may close it.</p><p>&#160;&#160;&#160;&#160; */</p><p>&#160;&#160;&#160; TopicConnection topicConnection;</p><p>&#160;&#160;&#160; /**</p><p>&#160;&#160;&#160;&#160; * Topic session, hold on to this so you may close it.</p><p>&#160;&#160;&#160;&#160; * Also used to create messages.</p><p>&#160;&#160;&#160;&#160; */</p><p>&#160;&#160;&#160; TopicSession topicSession;</p><p>&#160;&#160;&#160; /**</p><p>&#160;&#160;&#160;&#160; * Use this to publish messages.</p><p>&#160;&#160;&#160;&#160; */</p><p>&#160;&#160;&#160; TopicPublisher topicPublisher;</p><p>&#160;&#160;&#160; /**</p><p>&#160;&#160;&#160;&#160; * Destination where to publish.</p><p>&#160;&#160;&#160;&#160; */</p><p>&#160;&#160;&#160; Topic topic;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160; /**</p><p>&#160;&#160;&#160;&#160; * Sets up all the JMS fixtures.</p><p>&#160;&#160;&#160;&#160; *</p><p>&#160;&#160;&#160;&#160; * Use close() when finished with object.</p><p>&#160;&#160;&#160;&#160; *</p><p>&#160;&#160;&#160;&#160; * @param factoryJNDI name of the topic connection factory to look up.</p><p>&#160;&#160;&#160;&#160; * @param topicJNDI name of the topic destination to look up</p><p>&#160;&#160;&#160;&#160; */</p><p>&#160;&#160;&#160; public NewClass(String factoryJNDI, String topicJNDI)</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; throws JMSException, NamingException {</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; // Populate with needed properties</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Hashtable props = new Hashtable();</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; props.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; props.put(Context.PROVIDER_URL, "192.168.1.218:1099");</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; props.put("java.naming.rmi.security.manager", "yes");</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; props.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; // Get the initial context with given properties</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Context context = new InitialContext(props);</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; System.out.println(factoryJNDI);</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; // Get the initial context</p><p>&#160;&#160;&#160;&#160;&#160;&#160; // Context context = new InitialContext();</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; // Get the connection factory</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; TopicConnectionFactory topicFactory = (TopicConnectionFactory) context.lookup("java:/XAConnectionFactory");</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; // Create the connection</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; topicConnection = topicFactory.createTopicConnection();</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; // Create the session</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; topicSession = topicConnection.createTopicSession(</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; // No transaction</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; false,</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; // Auto ack</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Session.AUTO_ACKNOWLEDGE);</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; // Look up the destination</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; topic = (Topic) context.lookup(topicJNDI);</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; // Create a publisher</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; topicPublisher = topicSession.createPublisher(topic);</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160; }</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160; /**</p><p>&#160;&#160;&#160;&#160; * Publish the given String as a JMS message to the testTopic topic.</p><p>&#160;&#160;&#160;&#160; */</p><p>&#160;&#160;&#160; public void publish(String msg) throws JMSException {</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; // Create a message</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; TextMessage message = topicSession.createTextMessage();</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; message.setText(msg);</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; // Publish the message</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; topicPublisher.publish(topic, message);</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160; }</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160; /**</p><p>&#160;&#160;&#160;&#160; * Close session and connection.</p><p>&#160;&#160;&#160;&#160; * When done, no publishing is possible any more.</p><p>&#160;&#160;&#160;&#160; */</p><p>&#160;&#160;&#160; public void close() throws JMSException {</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; topicSession.close();</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; topicConnection.close();</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160; }</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160; /**</p><p>&#160;&#160;&#160;&#160; * Run an example publishing 10 messages to testTopic.</p><p>&#160;&#160;&#160;&#160; * Only works up to and including JBoss 2.4.0</p><p>&#160;&#160;&#160;&#160; */</p><p>&#160;&#160;&#160; public static void main(String[] args) {</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; try {</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; // Create the HelloPublisher, giving it the name of the</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; // TopicConnection Factory and the Topic destination to</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; // use in lookup.</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; NewClass publisher = new NewClass("ConnectionFactory","topic/testTopic1");</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; // Publish 10 messages</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; for (int i = 1; i &lt; 11; i++) {</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; String msg = "Hello World no. " + i;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; System.out.println("Publishing message: " + msg);</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; publisher.publish(msg);</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; // Close down your publisher</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; publisher.close();</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; catch (Exception ex)</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; System.err.println("An exception occurred while testing HelloPublisher: " + ex);</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; ex.printStackTrace();</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160; }</p><p>} // HelloPublisher</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><strong>MDB For reciving on Client End</strong></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>package com;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>import java.util.logging.Level;</p><p>import java.util.logging.Logger;</p><p>import javax.ejb.ActivationConfigProperty;</p><p>import javax.ejb.MessageDriven;</p><p>import javax.jms.JMSException;</p><p>import javax.jms.Message;</p><p>import javax.jms.MessageListener;</p><p>import javax.jms.TextMessage;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>@MessageDriven(mappedName = "topic/testTopic", </p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160; activationConfig =&#160; {</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; @ActivationConfigProperty(propertyName = "destination", propertyValue = "topic/testTopic"),</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; @ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge"),</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Topic"),</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; @ActivationConfigProperty(propertyName = "subscriptionDurability", propertyValue = "NonDurable"),</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; @ActivationConfigProperty(propertyName = "clientId", propertyValue = "DrivenBean6"),</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; @ActivationConfigProperty(propertyName = "subscriptionName", propertyValue = "DrivenBean6")</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; })</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>public class DrivenBean implements MessageListener {</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160; public DrivenBean() {</p><p>&#160;&#160;&#160; }</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160;&#160; TextMessage tx=null;</p><p>&#160;&#160;&#160; public void onMessage(Message message)</p><p>&#160;&#160;&#160; {</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; tx=(TextMessage) message;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; try {</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; System.out.println("Driven Bean -&gt; " + tx.getText());</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; } catch (JMSException ex) {</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; System.out.println("Hello");</p><p>&#160;&#160;&#160; }</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>}</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>What Settings are required so that i could send message to client end.</p></div>

<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
    <p style="margin: 0;">Reply to this message by <a href="http://community.jboss.org/message/603174#603174">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in JBoss Messaging at <a href="http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2042">Community</a></p>
</div></td>
                        </tr>
                    </tbody>
                </table>


                </td>
            </tr>
        </tbody>
    </table>

</div>

</body>
</html>