c# - Starting multiple threads in a for loop as no effect -


i'm trying read off messages websphere mq queue , dump in queue.

below code have it

private void transfermessages() {     mqqueuemanager sqmgr = connecttoqueuemanager(s_server_name, s_qmgr_name, s_port_number, s_channel_name);     mqqueuemanager dqmgr = connecttoqueuemanager(d_server_name, d_qmgr_name, d_port_number, d_channel_name);     if (sqmgr != null && dqmgr != null)     {         mqqueue sq = opensourcequeuetoget(sqmgr, s_queue_name);         mqqueue dq = opendestqueuetoput(dqmgr, d_queue_name);         if (sq != null && dq != null)         {             setputmessageoptions();             setgetmessageoptions();             processmessages(sqmgr, sq, dqmgr, dq);         }     } } 

and i'm calling above method in loop , creating separate threads below.

int no_of_threads = 5; thread[] ts = new thread[no_of_threads]; (int = 0; < no_of_threads; i++) {      ts[i] = new thread(() => transfermessages());     ts[i].start();         } 

as see, i'm making fresh connection queue manager in transfermessages method. not sure reason, program makes 1 connection mq.

the custom method connect queue manager below..

    private mqqueuemanager connecttoqueuemanager(string mqservername, string mqqueuemanagername, string mqportnumber, string mqchannel)     {         try         {             mqerrorstring = "";             mqqueuemanager qmgr;             hashtable mqprops = new hashtable();             mqprops.add(mqc.host_name_property, mqservername);             mqprops.add(mqc.channel_property, mqchannel);             mqprops.add(mqc.port_property, convert.toint32(mqportnumber));             mqprops.add(mqc.transport_property, mqc.transport_mqseries_client);             qmgr = new mqqueuemanager(mqqueuemanagername, mqprops);             return qmgr;         }         catch (mqexception mqex)         {             //catch , log mqexception here             return null;         }     } 

any advise missing?

that because of shared conversation (sharecnv) feature of mq multiple connections queue manager 1 application share same socket. value negotiated between client , queue manager while establishing connection. default 10 connections shared on socket.

you can increase number of threads in application 11, can see second connection being opened. more details on sharecnv here.

update channel status when running 6 threads each put , get. note connecting same queue manager (test purpose only). sharecnv set 10.

     2 : dis chstatus(my.svrconn) amq8417: display channel status details.    channel(my.svrconn)                     chltype(svrconn)    conname(127.0.0.1)                      current    status(running)                         substate(receive) amq8417: display channel status details.    channel(my.svrconn)                     chltype(svrconn)    conname(127.0.0.1)                      current    status(running)                         substate(receive) 

when running 5 threads each.

 3 : dis chstatus(my.svrconn) amq8417: display channel status details.    channel(my.svrconn)                     chltype(svrconn)    conname(127.0.0.1)                      current    status(running)                         substate(receive) 

Comments

Popular posts from this blog

android - Gradle sync Error:Configuration with name 'default' not found -

java - Andrioid studio start fail: Fatal error initializing 'null' -

html - jQuery UI Sortable - Remove placeholder after item is dropped -