Re: [clojure-rabbitmq] The execution hangs when nested publish inside consumer handler function

2015-07-22 Thread Nuttanart Pornprasitsakul
I posted the code snippet that can cause the issue on github. Also posted 
differences in network trace between blocking and success run that I've 
noticed there.

The output from rabbitmqctl eval `rabbitmq_diagnostics:maybe_stuck().` is

Error: {undef,[{rabbitmq_diagnostics,maybe_stuck,[],[]},
   {erl_eval,do_apply,6,[{file,erl_eval.erl},{line,657}]},
   {rpc,'-handle_call_call/6-fun-0-',5,
[{file,rpc.erl},{line,205}]}]}

On Tuesday, July 21, 2015 at 5:47:44 PM UTC+7, Michael Klishin wrote:

 On 21 Jul 2015 at 11:17:50, Nuttanart Pornprasitsakul (visib...@gmail.com 
 javascript:) wrote: 
  Follow up from the issue #74 I created on Github(
 https://github.com/michaelklishin/langohr/issues/74).   
  Sorry that I posted there. 

  It doesn't eventually unblock, both in and out queue are in idle   
  state not flow state. I'll get back again with the log and thread   
  dump. 

 There’s nothing unusual in the thread stack traces. We need a Wireshark 
 protocol 
 capture. 

 rabbitmqctl eval `rabbitmq_diagnostics:maybe_stuck().` output may also 
 help. 
 --   
 MK   

 Staff Software Engineer, Pivotal/RabbitMQ   




-- 
You received this message because you are subscribed to the Google Groups 
clojure-rabbitmq group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure-rabbitmq+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [clojure-rabbitmq] The execution hangs when nested publish inside consumer handler function

2015-07-22 Thread Michael Klishin
 On 22 Jul 2015 at 10:46:18, Nuttanart Pornprasitsakul (visiblet...@gmail.com) 
wrote:
 I posted the code snippet that can cause the issue on github.  
 Also posted differences in network trace between blocking and  
 success run that I've noticed there.

Thanks, this is a fairly busy week for me with 3 releases but I will take a look
in the next few days.

 The output from rabbitmqctl eval `rabbitmq_diagnostics:maybe_stuck().`  
 is
  
 Error: {undef,[{rabbitmq_diagnostics,maybe_stuck,[],[]},  
 {erl_eval,do_apply,6,[{file,erl_eval.erl},{line,657}]},  
 {rpc,'-handle_call_call/6-fun-0-',5,
 [{file,rpc.erl},{line,205}]}]}

This means your version doesn’t have that function (it’s fairly new, I think 
3.5.x)
--  
MK  

Staff Software Engineer, Pivotal/RabbitMQ  


-- 
You received this message because you are subscribed to the Google Groups 
clojure-rabbitmq group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure-rabbitmq+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[clojure-rabbitmq] Re: Reusing channel in message handler function

2015-07-22 Thread Michael Klishin
On Wednesday, July 22, 2015 at 12:14:36 PM UTC+3, Nuttanart Pornprasitsakul 
wrote:

 Hi,

 This question is related to blocking issue that I'm asking 
 https://github.com/michaelklishin/langohr/issues/74, but I think better 
 separating this to prevent putting more noises in that issue. I started to 
 think that the issue that happens to me causes by opening and closing 
 channel to often in the subscribe handler function (the snippet below 
 extracted from here 
 https://github.com/michaelklishin/langohr/issues/74#issuecomment-123536849
 )

 (lc/subscribe channel source (fn [ch meta message]
 (let [pub-ch (lch/open conn)]
   (lb/publish pub-ch  destination (str 
 message))
   (lch/close pub-ch))
 (lb/ack ch (:delivery-tag meta

 The reason I keep doing it this way is because in the Java RabbitMQ 
 client Channel documentation 
 https://www.rabbitmq.com/releases/rabbitmq-java-client/current-javadoc/com/rabbitmq/client/Channel.html
  
 says that a channel shouldn't be shared between threads. As my 
 understanding, message handler function can be executed in multiple threads 
 that's why I create a new channel and close it within the handler function. 
 But from my other test results, it seems like sharing channel between 
 threads making handler function run a lot faster and importantly, blocking 
 issue doesn't happen.


You can reuse the channel in this particular case. Yes, consumer methods 
will be executed in a thread pool but
per-channel ordering is guaranteed by the Java client (ConsumerWorkService, 
in case you wonder). I didn't
realise you were closing and opening channels inside a delivery handler. 
That should not be necessary and sounds
more dangerous than technically having channel sharing ;)

Thread sharing is a no-go if you intend to publish on a channel 
concurrently. As I explained in above,
Java client will effectively make publishing sequential in your case.
 
If this solves the blocking issue for you, I'd simply recommend you publish 
responses on the same
channel your deliveries are on (this is why the callback has `ch` as the 
first argument!) and move on :)

MK

-- 
You received this message because you are subscribed to the Google Groups 
clojure-rabbitmq group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure-rabbitmq+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.