Skip to content
This repository has been archived by the owner on Jun 16, 2022. It is now read-only.

Commit

Permalink
Added logging to test why client stops calling server proxy method.
Browse files Browse the repository at this point in the history
  • Loading branch information
DJGosnell committed Sep 8, 2016
1 parent 9b79cb4 commit 7c897f9
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 29 deletions.
20 changes: 13 additions & 7 deletions DtronixMessageQueue.Rpc/RpcProxy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,14 @@ public override IMessage Invoke(IMessage msg) {
RpcReturnCallWait return_wait = null;

// Determine what kind of method we are calling.
rw_store.MessageWriter.Write((byte) RpcMessageType.RpcCall);
if (method_info.ReturnType == typeof(void)) {
rw_store.MessageWriter.Write((byte)RpcMessageType.RpcCallNoReturn);
} else {
rw_store.MessageWriter.Write((byte)RpcMessageType.RpcCall);

return_wait = session.CreateReturnCallWait();
rw_store.MessageWriter.Write(return_wait.Id);
return_wait = session.CreateReturnCallWait();
rw_store.MessageWriter.Write(return_wait.Id);
}

rw_store.MessageWriter.Write(decorated.Name);
rw_store.MessageWriter.Write(method_call.MethodName);
Expand All @@ -59,12 +63,14 @@ public override IMessage Invoke(IMessage msg) {

session.Send(rw_store.MessageWriter.ToMessage(true));

if (return_wait == null) {
return new ReturnMessage(null, null, 0, method_call.LogicalCallContext, method_call);
}

return_wait.ReturnResetEvent.Wait(return_wait.Token);
//return new ReturnMessage(1, null, 0, method_call.LogicalCallContext, method_call);


try {
if (return_wait == null) {
return new ReturnMessage(null, null, 0, method_call.LogicalCallContext, method_call);
}
rw_store.MessageReader.Message = return_wait.ReturnMessage;

// Skip 3 bytes.
Expand Down
21 changes: 11 additions & 10 deletions DtronixMessageQueue.Rpc/RpcSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,20 +115,21 @@ private void ProcessRpc(MqMessage message, IncomingMessageEventArgs<TSession> e,
var method_info = service.GetType().GetMethod(method_name);
var method_parameters = method_info.GetParameters();

object[] parameters = new object[argument_count];

switch (message_type) {
case RpcMessageType.RpcCall:
object[] parameters = new object[argument_count];
// Deserialize each parameter.
JObject param_jobject = (JObject)store.Serializer.Deserialize(store.BsonReader);
var param_children = param_jobject.PropertyValues().ToArray();

for (int i = 0; i < argument_count; i++) {
parameters[i] = param_children[i].ToObject(method_parameters[i].ParameterType);
}

// Deserialize each parameter.
JObject param_jobject = (JObject)store.Serializer.Deserialize(store.BsonReader);
var param_children = param_jobject.PropertyValues().ToArray();
var return_value = method_info.Invoke(service, parameters);

for (int i = 0; i < argument_count; i++) {
parameters[i] = param_children[i].ToObject(method_parameters[i].ParameterType);
}

var return_value = method_info.Invoke(service, parameters);
switch (message_type) {
case RpcMessageType.RpcCall:

store.MessageWriter.Clear();
store.MessageWriter.Write((byte)RpcMessageType.RpcCallReturn);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using DtronixMessageQueue.Rpc;

Expand All @@ -18,7 +19,8 @@ class TestService : MarshalByRefObject, ITestService {
private bool completed = false;

public void TestNoReturn() {
call_count++;
var number = Interlocked.Increment(ref call_count);
Console.Write(number + " ");
VerifyComplete();

}
Expand Down
22 changes: 11 additions & 11 deletions DtronixMessageQueue/NLog.config
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd"
autoReload="true"
throwExceptions="false"
internalLogLevel="Off" internalLogFile="c:\temp\nlog-internal.log" >
<targets>
<target xsi:type="NLogViewer"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd"
autoReload="true"
throwExceptions="false"
internalLogLevel="Off" internalLogFile="c:\temp\nlog-internal.log" >
<targets>
<target xsi:type="NLogViewer"
name="viewer"
includeSourceInfo="true"
address="udp://127.0.0.1:9999"/>
</targets>
</targets>

<rules>
<logger name="DtronixMessageQueue.*" minlevel="Trace" writeTo="viewer" />
</rules>
<rules>
<logger name="DtronixMessageQueue.*" minlevel="Trace" writeTo="viewer" />
</rules>
</nlog>

0 comments on commit 7c897f9

Please sign in to comment.