JMS(Jboss Messaging)的一點使用心得(八)JBoss invoke-動態修改Bridge

下面是利用Invoke修改Bridge的代碼

    
private void openBridge() {
        
try {
            Context context;
            Hashtable 
<String, String> jndiMap = new Hashtable <String, String>();
            jndiMap.put(Context.INITIAL_CONTEXT_FACTORY, 
"org.jnp.interfaces.NamingContextFactory");
            jndiMap.put(Context.URL_PKG_PREFIXES, 
"org.jboss.naming:org.jnp.interfaces");
            jndiMap.put(Context.PROVIDER_URL, 
"172.60.0.126:1099");
            context 
= new InitialContext(jndiMap);
            MBeanServerConnection server 
= (MBeanServerConnection) context.lookup("jmx/invoker/RMIAdaptor");

            server.invoke(
new ObjectName("jboss.messaging:service=JMSProviderLoader,name=RemoteJMSProvider"),
                          
"stop",
                          
new Object[] {},
                          
new String[] {});

            Properties pro 
= new Properties();
            pro.put(
"java.naming.factory.initial""org.jnp.interfaces.NamingContextFactory");
            pro.put(
"java.naming.factory.url.pkgs""org.jboss.naming:org.jnp.interfaces");
            pro.put(
"java.naming.provider.url""172.60.0.128:1099");
            server.invoke(
new ObjectName("jboss.messaging:service=JMSProviderLoader,name=RemoteJMSProvider"),
                          
"setProperties",
                          
new Object[] {pro},
                          
new String[] {"java.util.Properties"});
            server.setAttribute(
new ObjectName("jboss.messaging:service=Bridge,name=Bridge_Test"),
                                
new Attribute("TargetUsername""digitalCinema"));
            server.setAttribute(
new ObjectName("jboss.messaging:service=Bridge,name=Bridge_Test"),
                                
new Attribute("TargetPassword""digitalCinema"));
            server.setAttribute(
new ObjectName("jboss.messaging:service=Bridge,name=Bridge_Test"),
                                
new Attribute("TargetDestinationLookup""/queue/B"));

            server.invoke(
new ObjectName("jboss.messaging:service=JMSProviderLoader,name=RemoteJMSProvider"),
                          
"start",
                          
new Object[] {},
                          
new String[] {});
        }
 catch (Exception e) {
            e.printStackTrace();
        }

    }
 
  
發佈了29 篇原創文章 · 獲贊 1 · 訪問量 9萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章