[jboss-user] [JBoss Messaging] - Re: Jboss Messaging How To

sudheer_java26 do-not-reply at jboss.com
Tue Apr 22 06:09:11 EDT 2008


As u suggested I created "my-factories-service.xml" and kept under 
"C:\myjboss-4.2.2\jboss-4.2.2.GA\server\messaging\deploy\"


Content of "my-factories-service.xml" 
---------
<mbean code="org.jboss.jms.server.connectionfactory.ConnectionFactory"
  |       name="jboss.messaging.connectionfactory:service=MyExampleConnectionFactory"
  |       xmbean-dd="xmdesc/ConnectionFactory-xmbean.xml">
  |       <constructor>
  |          <arg type="java.lang.String" value="MyClientID"/>
  |       </constructor>
  |       <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>
  |       <depends optional-attribute-name="Connector">jboss.messaging:service=Connector,transport=http</depends>
  |       <depends>jboss.messaging:service=PostOffice</depends>
  |       <attribute name="PrefetchSize">150</attribute>
  |       <attribute name="DefaultTempQueueFullSize">200000</attribute>
  |       <attribute name="DefaultTempQueuePageSize">2000</attribute>
  |       <attribute name="DefaultTempQueueDownCacheSize">2000</attribute>
  |       <attribute name="DupsOKBatchSize">5000</attribute>
  |       <attribute name="SupportsFailover">false</attribute>
  |       <attribute name="SupportsLoadBalancing">false</attribute>  
  |       <attribute name="LoadBalancingFactory">org.jboss.jms.client.plugin.RoundRobinLoadBalancingFactory</attribute> <attribute name="StrictTck">true</attribute>
  |       <attribute name="DisableRemotingChecks">false</attribute>
  |       <attribute name="JNDIBindings">
  |          <bindings>
  |             <binding>/acme/MyExampleConnectionFactory</binding>
  |             <binding>/acme/MyExampleConnectionFactoryDupe</binding>
  |             <binding>java:/xyz/CF1</binding>
  |             <binding>java:/connectionfactories/acme/connection_factory</binding>
  |          </bindings>
  |       </attribute>   
  |    </mbean>
-----------

 



I am using eclipse IDE, I took jars as fallows 

Jboss-j2ee.jar  	[JbossDIR] \server\messaging\lib
jpnserver.jar	        [JbossDIR] \server\messaging\lib
jbossmq.jar 	        [JbossDIR]\server\default\lib\
jboss-common.jar 	[JbossDIR]\lib\
concurrent.jar    	[JbossDIR]\lib\
  

 

Source code is 
=======================
import java.util.Properties;
  | 
  | import javax.jms.JMSException;
  | import javax.jms.TextMessage;
  | import javax.jms.Topic;
  | import javax.jms.TopicConnection;
  | import javax.jms.TopicConnectionFactory;
  | import javax.jms.TopicPublisher;
  | import javax.jms.TopicSession;
  | import javax.naming.Context;
  | import javax.naming.InitialContext;
  | import javax.naming.NamingException;
  | 
  | 
  | 
  | public class Sender {
  | 
  | String url_;
  | String name_;
  | TopicConnection conn = null;
  | TopicSession session = null;
  | Topic topic = null;
  | 
  | public Sender(String url, String name) throws JMSException, NamingException {
  | 
  | url_ = url;
  | name_ = name;
  | 
  | this.initializeSender();
  | 
  | }
  | 
  | private void initializeSender() throws JMSException, NamingException {
  | 
  | 
  | Properties props = new Properties();
  | props.setProperty("java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory");
  | props.setProperty("java.naming.factory.url.pkgs", "org.jboss.naming");
  | props.setProperty("java.naming.provider.url", url_);
  | 
  | Context context = new InitialContext(props);
  | 
  | TopicConnectionFactory tcf = (TopicConnectionFactory) context.lookup("ConnectionFactory");
  | conn = tcf.createTopicConnection();
  | topic = (Topic) context.lookup(name_);
  | 
  | session = conn.createTopicSession(false, TopicSession.AUTO_ACKNOWLEDGE);
  | conn.start();
  | 
  | }
  | 
  | public void send(String text) throws JMSException	, NamingException {
  | 
  | // Send a text msg
  | TopicPublisher send = session.createPublisher(topic);
  | TextMessage tm = session.createTextMessage(text);
  | send.publish(tm);
  | send.close();
  | }
  | 
  | 
  | public void disconnect() throws JMSException {
  | if(conn != null) {
  | conn.stop();
  | }
  | 
  | if(session != null) {
  | session.close();
  | }
  | 
  | if(conn != null) {
  | conn.close();
  | }
  | }
  | 
  | public String getTopicName() {
  | return name_;
  | }
  | 
  | public String getTopicURL() {
  | return url_;
  | }
  | 
  | public static void main(String args[]) throws Exception {
  | 
  | System.out.println("Starting JMS Example Sender");
  | 
  | Sender sender = new Sender("localhost:1099", "topic/testTopic");
  | 
  | System.out.println("Sending list of Adam Sandler Movies");
  | 
  | sender.send("deepak");
  | sender.send("mehir");
  | sender.send("ravi");
  | sender.send("test");
  | sender.send("Mr.Deeds 2002");
  | sender.send("Eight Crazy Nights 2002");
  | sender.send("Anger Management 2003");
  | 
  | sender.disconnect();
  | 
  | System.out.println("JMS Example Sender Complete - list sent");
  | 
  | }
  | 
  | }
-------



After running server as 

C:\myjboss-4.2.2\jboss-4.2.2.GA\bin>run -c messaging

i am getting fallowing msg in dos window
---------------------
.
  | .
  | .
  | 
  | 15:13:51,890 INFO  [TopicService] Topic[/topic/TopicWithOwnDLQAndExpiryQueue] st
  | arted, fullSize=200000, pageSize=2000, downCacheSize=2000
  | 15:13:51,890 INFO  [QueueService] Queue[/queue/QueueWithOwnRedeliveryDelay] star
  | ted, fullSize=200000, pageSize=2000, downCacheSize=2000
  | 15:13:51,890 INFO  [TopicService] Topic[/topic/TopicWithOwnRedeliveryDelay] star
  | ted, fullSize=200000, pageSize=2000, downCacheSize=2000
  | 15:13:51,890 INFO  [QueueService] Queue[/queue/testDistributedQueue] started, fu
  | llSize=200000, pageSize=2000, downCacheSize=2000
  | 15:13:51,890 INFO  [TopicService] Topic[/topic/testDistributedTopic] started, fu
  | llSize=200000, pageSize=2000, downCacheSize=2000
  | 15:13:51,890 INFO  [TopicService] Topic[/topic/myTopic] started, fullSize=200000
  | , pageSize=2000, downCacheSize=2000
  | 15:13:52,062 INFO  [ConnectionFactoryBindingService] Bound ConnectionManager 'jb
  | oss.jca:service=ConnectionFactoryBinding,name=JmsXA' to JNDI name 'java:JmsXA'
  | 15:13:52,093 INFO  [TomcatDeployer] deploy, ctxPath=/jmx-console, warUrl=.../dep
  | loy/jmx-console.war/
  | 15:13:52,234 ERROR [URLDeploymentScanner] Incomplete Deployment listing:
  | 
  | --- MBeans waiting for other MBeans ---
  | ObjectName: jboss.messaging.connectionfactory:service=MyExampleConnectionFactory
  | 
  |   State: CONFIGURED
  |   I Depend On:
  |     jboss.messaging:service=ServerPeer
  |     jboss.messaging:service=Connector,transport=http
  |     jboss.messaging:service=PostOffice
  | 
  | --- MBEANS THAT ARE THE ROOT CAUSE OF THE PROBLEM ---
  | ObjectName: jboss.messaging:service=Connector,transport=http
  |   State: NOTYETINSTALLED
  |   Depends On Me:
  |     jboss.messaging.connectionfactory:service=MyExampleConnectionFactory
  | 
  | 
  | 15:13:52,359 INFO  [Http11Protocol] Starting Coyote HTTP/1.1 on http-127.0.0.1-8
  | 080
  | 15:13:52,390 INFO  [AjpProtocol] Starting Coyote AJP/1.3 on ajp-127.0.0.1-8009
  | 15:13:52,390 INFO  [Server] JBoss (MX MicroKernel) [4.2.2.GA (build: SVNTag=JBos
  | s_4_2_2_GA date=200710221139)] Started in 17s:937ms------------------------------------


and when I run Sender.java, I am getting 

Starting JMS Example Sender
  | Exception in thread "main" javax.naming.NameNotFoundException: MyExampleConnectionFactory not bound
  | 
  | at org.jnp.server.NamingServer.getBinding(NamingServer.java:529)
  | at org.jnp.server.NamingServer.getBinding(NamingServer.java:537)


This above example i am able to execute correctly using 
default connection factory i.e "ConnectionFactory" 
and using testTopic as destination.
*** When i start server by clicking "C:\myjboss-4.2.2\jboss-4.2.2.GA\bin\run.bat"


Please help me in this, what will be the mistake here ? 


---------
-Sudheer

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4145751#4145751

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4145751



More information about the jboss-user mailing list