On my machine I noticed that when sending multiple logging events to a SocketAppender, only the first event gets serialized and sent over the wire to a ServerSocketReceiver.
Debuging the code, I found out that for sending loggingEvents the SocketAppender uses either a SynchronousQueue or an ArrayBlockingQueue in order to make producer-consumer and send serialized events to the socket. That BlockingQueue does behave erratically on my machine.
To demonstrate that I included a small java test that will send 3 events to a SynchronousQueue and to an ArrayBlockingQueue and the output is this:
-
-
- start test SynchronousQueue###
+ appender thread started
- send 3 events
- no more events to be sent
+ received event 1
+ appender thread ended
-
- end test ###
- start test ArrayBlockingQueue[2]###
+ appender thread started
- send 3 events
- no more events to be sent
-
- end test ###
- start test ArrayBlockingQueue[3]###
+ appender thread started
- send 3 events
- no more events to be sent
+ received event 1
+ received event 2
+ received event 3
+ appender thread ended
-
- end test ###
This shows that the SynchronousQueue only process the first event and ArrayBlockingQueue[2] does not work at all.
Another test iteration:
-
-
- start test SynchronousQueue###
+ appender thread started
- send 3 events
- no more events to be sent
+ received event 1
+ appender thread ended
-
- end test ###
- start test ArrayBlockingQueue[2]###
+ appender thread started
- send 3 events
- no more events to be sent
+ received event 1
+ received event 2
+ appender thread ended
-
- end test ###
- start test ArrayBlockingQueue[3]###
+ appender thread started
- send 3 events
- no more events to be sent
+ received event 1
+ received event 2
+ received event 3
+ appender thread ended
-
- end test ###
This time the SynchronousQueue only processes the first event and the ArrayBlockingQueue[2] processes the first 2 events.
|