When my endpoint does Bus.Reply() to I a message sent with Bus.SendLocal(), I get the following error message which causes the message to fail:
2013-02-28 13:54:16,994 [Worker.15] WARN NServiceBus.Unicast.Transport.Transact
ional.TransactionalTransport [(null)] <(null)> - Failed raising 'transport messa
ge received' event for message with ID=42e4b3ed-d0a2-4ab0-acfb-3531d8dafa3e\2056
7
NServiceBus.Unicast.Transport.TransportMessageHandlingFailedException: Exception
of type 'NServiceBus.Unicast.Transport.TransportMessageHandlingFailedException'
was thrown.
at NServiceBus.Unicast.UnicastBus.HandleTransportMessage(IBuilder childBuilde
r, TransportMessage msg) in c:\BuildAgent\work\nsb.master_6\src\unicast\NService
Bus.Unicast\UnicastBus.cs:line 1331
at NServiceBus.Unicast.UnicastBus.TransportMessageReceived(Object sender, Tra
nsportMessageReceivedEventArgs e) in c:\BuildAgent\work\nsb.master_6\src\unicast
\NServiceBus.Unicast\UnicastBus.cs:line 1248
at System.EventHandler`1.Invoke(Object sender, TEventArgs e)
at NServiceBus.Unicast.Transport.Transactional.TransactionalTransport.OnTrans
portMessageReceived(TransportMessage msg) in c:\BuildAgent\work\nsb.master_6\src
\impl\unicast\transport\NServiceBus.Unicast.Transport.Transactional\Transactiona
lTransport.cs:line 480
Here's my configuration:
Configure
.With(AllAssemblies.Except("evointernal.dll")) // This is a COM assembly and should not be scanned.
.StructureMapBuilder(ObjectFactory.Container)
.JsonSerializer()
.UnicastBus().DoNotAutoSubscribe()
.Sagas();
Related
I am trying some edge cases in my software. So I have created a very simple test environment:
RabbitMQ server running on CentOS 7
Message consumer written against .NETCore 2.1 in C# running under CentOS 7
Message sender written against .NETCore 2.1 in C# running under CentOS 7
I send a simple text message every 5 seconds. The sender and receiver run on the same UNIX box, while the RabbitMQ server runs on a different machine in the network.
So far so good. Now I stop my RabbitMQ server with systemctl stop rabbitmq-server.
I get errors on the sender and the receiver which was expected.
I restart the RabbitMQ server using systemctl start rabbitmq-server.
And now the fun starts! The sender can recover and continues to send messages but the consumer CANNOT recover and does not receive messages. They are accumulated on the RabbitMQ server!
Here are my log entries from the sender (which works as expected):
2019-01-22 21:18:25.628 +01:00 [ERR] [EasyNetQ.PersistentConnection] [ThreadId 10] Failed to connect to broker infraserver-tbws2, port 5672, vhost testvh
RabbitMQ.Client.Exceptions.BrokerUnreachableException: None of the specified endpoints were reachable ---> System.AggregateException: One or more errors occurred. (Connection failed) ---> RabbitMQ.Client.Exceptions.ConnectFailureException: Connection failed ---> System.Net.Internals.SocketExceptionFactory+ExtendedSocketException: Connection refused 172.16.63.239:5672
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw(Exception source)
at System.Net.Sockets.Socket.EndConnect(IAsyncResult asyncResult)
at System.Net.Sockets.Socket.<>c.<ConnectAsync>b__272_0(IAsyncResult iar)
--- End of stack trace from previous location where exception was thrown ---
at RabbitMQ.Client.TcpClientAdapter.ConnectAsync(String host, Int32 port)
at RabbitMQ.Client.Impl.TaskExtensions.TimeoutAfter(Task task, Int32 millisecondsTimeout)
at RabbitMQ.Client.Impl.SocketFrameHandler.ConnectOrFail(ITcpClient socket, AmqpTcpEndpoint endpoint, Int32 timeout)
--- End of inner exception stack trace ---
at RabbitMQ.Client.Impl.SocketFrameHandler.ConnectUsingAddressFamily(AmqpTcpEndpoint endpoint, Func`2 socketFactory, Int32 timeout, AddressFamily family)
at RabbitMQ.Client.Impl.SocketFrameHandler.ConnectUsingIPv4(AmqpTcpEndpoint endpoint, Func`2 socketFactory, Int32 timeout)
at RabbitMQ.Client.Impl.SocketFrameHandler..ctor(AmqpTcpEndpoint endpoint, Func`2 socketFactory, Int32 connectionTimeout, Int32 readTimeout, Int32 writeTimeout)
at RabbitMQ.Client.Framing.Impl.IProtocolExtensions.CreateFrameHandler(IProtocol protocol, AmqpTcpEndpoint endpoint, Func`2 socketFactory, Int32 connectionTimeout, Int32 readTimeout, Int32 writeTimeout)
at RabbitMQ.Client.ConnectionFactory.CreateFrameHandler(AmqpTcpEndpoint endpoint)
at RabbitMQ.Client.EndpointResolverExtensions.SelectOne[T](IEndpointResolver resolver, Func`2 selector)
--- End of inner exception stack trace ---
at RabbitMQ.Client.EndpointResolverExtensions.SelectOne[T](IEndpointResolver resolver, Func`2 selector)
at RabbitMQ.Client.ConnectionFactory.CreateConnection(IEndpointResolver endpointResolver, String clientProvidedName)
--- End of inner exception stack trace ---
at RabbitMQ.Client.ConnectionFactory.CreateConnection(IEndpointResolver endpointResolver, String clientProvidedName)
at RabbitMQ.Client.ConnectionFactory.CreateConnection(String clientProvidedName)
at EasyNetQ.ConnectionFactoryWrapper.CreateConnection()
at EasyNetQ.PersistentConnection.TryToConnect()
2019-01-22 21:18:25.632 +01:00 [ERR] [EasyNetQ.PersistentConnection] [ThreadId 10] Failed to connect to any Broker. Retrying in 00:00:05
2019-01-22 21:18:35.444 +01:00 [INF] [] [ThreadId 1] Sucessfully sent Message 'Message: 'This is test message number 7.' | Num: 7 | Guid: 5345c7e4-61e6-4c79-8179-d4bef7864420'.
2019-01-22 21:18:40.452 +01:00 [INF] [] [ThreadId 1] Sucessfully sent Message 'Message: 'This is test message number 8.' | Num: 8 | Guid: 3cd8635c-cdfa-45f3-8495-2acb0713d47b'.
2019-01-22 21:18:45.457 +01:00 [INF] [] [ThreadId 1] Sucessfully sent Message 'Message: 'This is test message number 9.' | Num: 9 | Guid: 099462b8-cd66-40b9-ac10-89c3246819ec'.
2019-01-22 21:18:50.470 +01:00 [INF] [] [ThreadId 1] Sucessfully sent Message 'Message: 'This is test message number 10.' | Num: 10 | Guid: c25139b2-8e45-4771-9544-830014382e0c'.
2019-01-22 21:18:55.515 +01:00 [INF] [] [ThreadId 1] Sucessfully sent Message 'Message: 'This is test message number 11.' | Num: 11 | Guid: 90049d91-3805-4aaa-ac18-b61c09164afd'.
2019-01-22 21:19:00.526 +01:00 [INF] [] [ThreadId 1] Sucessfully sent Message 'Message: 'This is test message number 12.' | Num: 12 | Guid: 108ff318-6a34-4e64-94bd-dafa67aa6717'.
This shows the last error message and then one can see that EasyNetQ recovered and can deliver messages again.
The message consumer does NOT work! Here my log entries:
2019-01-22 21:18:25.623 +01:00 [ERR] [EasyNetQ.PersistentConnection] [ThreadId 12] Failed to connect to broker infraserver-tbws2, port 5672, vhost testvh
RabbitMQ.Client.Exceptions.BrokerUnreachableException: None of the specified endpoints were reachable ---> System.AggregateException: One or more errors occurred. (Connection failed) ---> RabbitMQ.Client.Exceptions.ConnectFailureException: Connection failed ---> System.Net.Internals.SocketExceptionFactory+ExtendedSocketException: Connection refused 172.16.63.239:5672
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw(Exception source)
at System.Net.Sockets.Socket.EndConnect(IAsyncResult asyncResult)
at System.Net.Sockets.Socket.<>c.<ConnectAsync>b__272_0(IAsyncResult iar)
--- End of stack trace from previous location where exception was thrown ---
at RabbitMQ.Client.TcpClientAdapter.ConnectAsync(String host, Int32 port)
at RabbitMQ.Client.Impl.TaskExtensions.TimeoutAfter(Task task, Int32 millisecondsTimeout)
at RabbitMQ.Client.Impl.SocketFrameHandler.ConnectOrFail(ITcpClient socket, AmqpTcpEndpoint endpoint, Int32 timeout)
--- End of inner exception stack trace ---
at RabbitMQ.Client.Impl.SocketFrameHandler.ConnectUsingAddressFamily(AmqpTcpEndpoint endpoint, Func`2 socketFactory, Int32 timeout, AddressFamily family)
at RabbitMQ.Client.Impl.SocketFrameHandler.ConnectUsingIPv4(AmqpTcpEndpoint endpoint, Func`2 socketFactory, Int32 timeout)
at RabbitMQ.Client.Impl.SocketFrameHandler..ctor(AmqpTcpEndpoint endpoint, Func`2 socketFactory, Int32 connectionTimeout, Int32 readTimeout, Int32 writeTimeout)
at RabbitMQ.Client.Framing.Impl.IProtocolExtensions.CreateFrameHandler(IProtocol protocol, AmqpTcpEndpoint endpoint, Func`2 socketFactory, Int32 connectionTimeout, Int32 readTimeout, Int32 writeTimeout)
at RabbitMQ.Client.ConnectionFactory.CreateFrameHandler(AmqpTcpEndpoint endpoint)
at RabbitMQ.Client.EndpointResolverExtensions.SelectOne[T](IEndpointResolver resolver, Func`2 selector)
--- End of inner exception stack trace ---
at RabbitMQ.Client.EndpointResolverExtensions.SelectOne[T](IEndpointResolver resolver, Func`2 selector)
at RabbitMQ.Client.ConnectionFactory.CreateConnection(IEndpointResolver endpointResolver, String clientProvidedName)
--- End of inner exception stack trace ---
at RabbitMQ.Client.ConnectionFactory.CreateConnection(IEndpointResolver endpointResolver, String clientProvidedName)
at RabbitMQ.Client.ConnectionFactory.CreateConnection(String clientProvidedName)
at EasyNetQ.ConnectionFactoryWrapper.CreateConnection()
at EasyNetQ.PersistentConnection.TryToConnect()
2019-01-22 21:18:25.625 +01:00 [ERR] [EasyNetQ.PersistentConnection] [ThreadId 12] Failed to connect to any Broker. Retrying in 00:00:05
Here it sits and waits forever! Looks like the thing is deadlocked in a way while the messages are accumulating on the RabbitMQ server:
When I stop my consumer application and restart it, the messages are picked up.
I connect in both applications (sender and consumer) with the following code:
private static IBus SetupRabbitMqConnection(string rabbitServer, string rabbitVHost, ushort rabbitPort, string rabbitUser, string rabbitPwd)
{
Log.Logger.Debug($"Creating a connection to RabbitMQ server '{rabbitServer}' on port {rabbitPort.ToString()} " +
$"using the EasyNetQ library....");
try
{
var connStr = $"host={rabbitServer}:{rabbitPort.ToString()};virtualHost={rabbitVHost};username={rabbitUser};" +
$"password={rabbitPwd};publisherConfirms=true;timeout=30;prefetchcount=1;requestedHeartbeat=30";
var msgBus = RabbitHutch.CreateBus(connStr, x => { });
if (!msgBus.IsConnected)
{
var errMsg = $"Currently not connected to RabbitMQ server '{rabbitServer}'.";
Log.Logger.Error(errMsg);
}
Log.Logger.Debug("Successfully connected to RabbitMQ server.");
return msgBus;
}
catch (Exception ex)
{
Log.Logger.Error($"Error to establish a connection to RabbitMQ server '{rabbitServer}'. Error: {ex}");
throw;
}
}
The consumer program registers the listeners as follows:
var msgBus = SetupRabbitMqConnection(rabbitServer, vhost, rabbitPort, rabbitUser, rabbitPwd);
RegisterMsgSubscriptions(msgBus);
private static void RegisterMsgSubscriptions(IBus msgBus)
{
Log.Logger.Debug("Starting to register RabbitMQ message subscriptions...");
try
{
#region Queue declarations
var advancedBus = msgBus.Advanced;
var testQueueOne = new EasyNetQ.Topology.Queue(TestQueueOneName, true);
Log.Logger.Debug("Finished declaring queues.");
#endregion
#region Message Queue Handler registrations
advancedBus.Consume(testQueueOne, registration => registration
.Add<RabbitMessage<TestTextMessageDto>>(MessageProcessor.ProcessRabbitTestMessage));
Log.Logger.Debug("Finished registration of message handlers for several queues.");
#endregion
}
catch (Exception ex)
{
Log.Logger.Error($"Error registering message handler. Error: {ex}");
}
}
Any idea what might go wrong here?? In production we have more than 100 servers consuming messages. These servers are on premise spread all over the country. The RabbitMQ server is in the data center. So the consuming servers MUST recover if the connection gets lost, otherwise this is not usable!
Just add subscription logic on connected event (It will be fired on every broker connected event).
advancedBus.Connected += (sender, args) => {
// subscribe logic
};
Of course You should handle not to call subscribe logice twice on any connect etc.
I am developing an application in vb.net it was working perfectly fine until this error occurred. I have tried everything but its of no use. Please Help me
ERROR:
Server Error in '/CNS/pdf' Application.
Exception of type java.lang.UnsatisfiedLinkError was thrown.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information about
the error and where it originated in the code.
Exception Details: java.lang.UnsatisfiedLinkError: Exception of type
java.lang.UnsatisfiedLinkError was thrown.
Source Error:
Line 1165: CheckedByName = dr.GetString(1)
Line 1166: CheckedByDesig = dr.GetString(2)
Line 1167: Case 3
Line 1168: ApprovedByName = dr.GetString(1)
Line 1169: ApprovedByDesig = dr.GetString(2)
Source File: C:\Inetpub\wwwroot\CNS\pdf\PdfForms.aspx.vb Line: 1167
Stack Trace:
[UnsatisfiedLinkError: Exception of type java.lang.UnsatisfiedLinkError was
thrown.]
java.lang.ExceptionInInitializerError.checkAndThrowException(Throwable
thrown) +59
java.io.File..cctor() +246
[TypeInitializationException: The type initializer for "java.io.File" threw an
exception.]
java.io.FileOutputStream..ctor(String path) +28
pdf.PdfForms.ShowPO(String PONo) in
C:\Inetpub\wwwroot\CNS\pdf\PdfForms.aspx.vb:1167
pdf.PdfForms.Page_Load(Object sender, EventArgs e) in
C:\Inetpub\wwwroot\CNS\pdf\PdfForms.aspx.vb:52
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Page.ProcessRequestMain() +750
I've downloaded and installed NServiceBus 4.0, but I'm having some difficulty when the bus starts up...
2013-09-18 15:53:40,887 [1] WARN NServiceBus.Persistence.Raven.RavenUserInstall
er [(null)] <(null)> - Failed to add user to raven. Processing will continue
System.MissingMethodException: Method not found: 'Raven.Abstractions.Data.PutRes
ult Raven.Client.Connection.IDatabaseCommands.Put(System.String, System.Nullable
`1, Raven.Json.Linq.RavenJObject, Raven.Json.Linq.RavenJObject)'.
at NServiceBus.Persistence.Raven.RavenUserInstaller.AddUserToDatabase(String
identity, DocumentStore documentStore)
at NServiceBus.Persistence.Raven.RavenUserInstaller.Install(String identity)
in c:\BuildAgent\work\d4de8921a0aabf04\src\NServiceBus.Core\Persistence\Raven\Ra
venUserInstaller.cs:line 40
also when I try to persist changes to the document store...
public class RavenUnitOfWork: IManageUnitsOfWork
{
public IDocumentSession Session { get; set; }
public void Begin()
{
}
public void End(Exception ex = null)
{
if (ex == null && Session != null)
{
Console.WriteLine("Saving Changes to DB.");
Session.SaveChanges();
}
}
}
produces
2013-09-18 15:57:38,007 [13] INFO NServiceBus.Unicast.Transport.TransportReceiv
er [(null)] <(null)> - Failed to process message
System.InvalidOperationException: Url: "/bulk_docs"
System.FormatException: Guid should contain 32 digits with 4 dashes (xxxxxxxx-xx
xx-xxxx-xxxx-xxxxxxxxxxxx).
at System.Guid.GuidResult.SetFailure(ParseFailureKind failure, String failure
MessageID, Object failureMessageFormatArgument, String failureArgumentName, Exce
ption innerException)
at System.Guid.TryParseGuidWithDashes(String guidString, GuidResult& result)
at System.Guid.TryParseGuid(String g, GuidStyles flags, GuidResult& result)
at System.Guid..ctor(String g)
at Raven.Database.Server.AbstractRequestResponder.GetRequestTransaction(IHttp
Context context)
at Raven.Database.Server.Responders.DocumentBatch.Respond(IHttpContext contex
t)
at Raven.Database.Server.HttpServer.DispatchRequest(IHttpContext ctx)
at Raven.Database.Server.HttpServer.HandleActualRequest(IHttpContext ctx)
---> System.Net.WebException: The remote server returned an error: (500) Intern
al Server Error.
at System.Net.HttpWebRequest.GetResponse()
at Raven.Client.Connection.HttpJsonRequest.ReadJsonInternal(Func`1 getRespons
e) in c:\Builds\RavenDB-Stable\Raven.Client.Lightweight\Connection\HttpJsonReque
st.cs:line 340
--- End of inner exception stack trace ---
at NServiceBus.Unicast.Transport.TransportReceiver.ProcessMessage(TransportMe
ssage message) in c:\BuildAgent\work\d4de8921a0aabf04\src\NServiceBus.Core\Unica
st\Transport\TransportReceiver.cs:line 357
at NServiceBus.Unicast.Transport.TransportReceiver.TryProcess(TransportMessag
e message) in c:\BuildAgent\work\d4de8921a0aabf04\src\NServiceBus.Core\Unicast\T
ransport\TransportReceiver.cs:line 235
at NServiceBus.Transports.Msmq.MsmqDequeueStrategy.ProcessMessage(TransportMe
ssage message) in c:\BuildAgent\work\d4de8921a0aabf04\src\NServiceBus.Core\Trans
ports\Msmq\MsmqDequeueStrategy.cs:line 262
at NServiceBus.Transports.Msmq.MsmqDequeueStrategy.Action() in c:\BuildAgent\
work\d4de8921a0aabf04\src\NServiceBus.Core\Transports\Msmq\MsmqDequeueStrategy.c
s:line 197
2013-09-18 15:57:38,129 [29] INFO NServiceBus.Unicast.Transport.TransportReceiv
er [(null)] <(null)> - Failed to process message
System.InvalidOperationException: Url: "/bulk_docs"
System.FormatException: Guid should contain 32 digits with 4 dashes (xxxxxxxx-xx
xx-xxxx-xxxx-xxxxxxxxxxxx).
at System.Guid.GuidResult.SetFailure(ParseFailureKind failure, String failure
MessageID, Object failureMessageFormatArgument, String failureArgumentName, Exce
ption innerException)
at System.Guid.TryParseGuidWithDashes(String guidString, GuidResult& result)
at System.Guid.TryParseGuid(String g, GuidStyles flags, GuidResult& result)
at System.Guid..ctor(String g)
at Raven.Database.Server.AbstractRequestResponder.GetRequestTransaction(IHttp
Context context)
at Raven.Database.Server.Responders.DocumentBatch.Respond(IHttpContext contex
t)
at Raven.Database.Server.HttpServer.DispatchRequest(IHttpContext ctx)
at Raven.Database.Server.HttpServer.HandleActualRequest(IHttpContext ctx)
---> System.Net.WebException: The remote server returned an error: (500) Intern
al Server Error.
at System.Net.HttpWebRequest.GetResponse()
at Raven.Client.Connection.HttpJsonRequest.ReadJsonInternal(Func`1 getRespons
e) in c:\Builds\RavenDB-Stable\Raven.Client.Lightweight\Connection\HttpJsonReque
st.cs:line 340
--- End of inner exception stack trace ---
at NServiceBus.Unicast.Transport.TransportReceiver.ProcessMessage(TransportMe
ssage message) in c:\BuildAgent\work\d4de8921a0aabf04\src\NServiceBus.Core\Unica
st\Transport\TransportReceiver.cs:line 357
at NServiceBus.Unicast.Transport.TransportReceiver.TryProcess(TransportMessag
e message) in c:\BuildAgent\work\d4de8921a0aabf04\src\NServiceBus.Core\Unicast\T
ransport\TransportReceiver.cs:line 235
at NServiceBus.Transports.Msmq.MsmqDequeueStrategy.ProcessMessage(TransportMe
ssage message) in c:\BuildAgent\work\d4de8921a0aabf04\src\NServiceBus.Core\Trans
ports\Msmq\MsmqDequeueStrategy.cs:line 262
at NServiceBus.Transports.Msmq.MsmqDequeueStrategy.Action() in c:\BuildAgent\
work\d4de8921a0aabf04\src\NServiceBus.Core\Transports\Msmq\MsmqDequeueStrategy.c
s:line 197
2013-09-18 15:57:38,262 [30] INFO NServiceBus.Unicast.Transport.TransportReceiv
er [(null)] <(null)> - Failed to process message
System.InvalidOperationException: Url: "/bulk_docs"
I've configured Raven as follows:
Configure.Instance.Configurer.ConfigureComponent<IDocumentStore>(() =>
{
var store = new DocumentStore
{
Url = "" // <-- Points to my machine at port 8080
};
store.Initialize();
store.JsonRequestFactory.DisableRequestCompression = true;
return store;
}, DependencyLifecycle.SingleInstance);
Configure.Instance.Configurer.ConfigureComponent<IDocumentSession>(() => { return Configure.Instance.Builder.Build<IDocumentStore>().OpenSession(); }, DependencyLifecycle.InstancePerUnitOfWork);
Configure.Instance.Configurer.ConfigureComponent<RavenUnitOfWork>(DependencyLifecycle.InstancePerUnitOfWork);
What am I missing here?
Thanks.
It's a known issue. See #1518. It's been fixed in #1551, but hasn't yet made it into a release. Either try building yourself from source, or wait for it to be included in a release.
Please make sure you are running Raven v2.
Raven v2.5 has not been tested against NServiceBus v4!
I fixed the MissingMethodException I was getting when using Raven Client 2.5 and NServiceBus 4.4.2 by adding an assembly binding redirect
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Raven.Client.Lightweight" publicKeyToken="37f41c7f99471593" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.5.0.0" newVersion="2.5.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
I am getting the below error when i call "NServiceBus.Host.exe". The issue appears to be itextsharp.dll. I've read that i can use
"Configure.With(AllAssemblies.Except("itextsharp.dll"))... // rest of your config"
But i'm using the following sample and not sure where to add this property.
http://docs.particular.net/samples/web/asp-mvc-application/
#
Unhandled Exception: Magnum.StateMachine.StateMachineException: Exception occurr
ed in Topshelf.Internal.ServiceController1[[NServiceBus.Host.Internal.GenericHo
st, NServiceBus.Host, Version=2.6.0.1504, Culture=neutral, PublicKeyToken=9fc386
479f8a226c]] during state Initial while handling OnStart ---> System.Exception:
Exception when starting endpoint, error has been logged. Reason: Could not load
file or assembly 'file:///D:\dev\MYSITE\MYSITE.EStore\EStore.Server\bin\Debug\itexts
harp.dll' or one of its dependencies. Operation is not supported. (Exception fro
m HRESULT: 0x80131515)
at NServiceBus.Host.Internal.GenericHost.Start() in d:\BuildAgent-02\work\20b
5f701adefe8f8\src\host\NServiceBus.Host\Internal\GenericHost.cs:line 90
at Magnum.StateMachine.EventActionList1.Execute(T stateMachine, Event event,
Object parameter) in :line 0
--- End of inner exception stack trace ---
Server stack trace:
at Magnum.StateMachine.ExceptionActionDictionary1.HandleException(T stateMac
hine, Event event, Object parameter, Exception exception) in :line 0
at Magnum.StateMachine.EventActionList1.Execute(T stateMachine, Event event,
Object parameter) in :line 0
at Magnum.StateMachine.State1.RaiseEvent(T instance, BasicEvent1 eevent, Ob
ject value) in :line 0
at Magnum.StateMachine.StateMachine`1.RaiseEvent(Event raised) in :line 0
at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(
IntPtr md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInCont
ext, Object[]& outArgs)
at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMes
sage msg, Int32 methodPtr, Boolean fExecuteInContext)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage req
Msg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgDa
ta, Int32 type)
at Topshelf.Internal.ServiceControllerProxy.Start()
at Topshelf.Internal.ServiceCoordinator.Start() in d:\dev\open-source\topshel
f\src\Topshelf\Internal\ServiceCoordinator.cs:line 54
at Topshelf.Internal.Hosts.ConsoleHost.Run() in d:\dev\open-source\topshelf\s
rc\Topshelf\Internal\Hosts\ConsoleHost.cs:line 53
at NServiceBus.Host.Program.Main(String[] args) in d:\BuildAgent-02\work\20b5
f701adefe8f8\src\host\NServiceBus.Host\Program.cs:line 103
When NserviceBus host starts it tries to retrieve all types from assemblies you specify.
In the sample you provide it uses NServiceBus.Configure.WithWeb() method.
This is the same as to call NServiceBus.Configure.With(AppDomain.CurrentDomain.DynamicDirectory)
You get the excpetion because "itextsharp.dll" cannot be loaded to AppDomain (this is done by calling Assembly.LoadFrom(file.FullName) method).
To fix the issue, you may manually specify assemblies you need to scan by using one of NServiceBus.Configure.With() overloads.
I'm a bit perplexed by an issue I'm getting on a particular deployment, but not
on my build machine. This is a web application that is receiving NServiceBus events to keep
a persistent view model updated. There are events waiting in the services incoming MSMQ, so the
subscription seems to be working correctly, but the application isn't processing
them. The output I'm getting is shown below. Sorry for the mass of text; the
summary is that the logs point to UnicastBus.Address being Nothing at runtime.
Perhaps something is missing in my configuration.
Here are the logs:
[Worker.11] INFO NServiceBus.Unicast.UnicastBus [(null)] -
Common.Users.WebApp.DevTest initialized.
[10] INFO NServiceBus.Unicast.UnicastBus [(null)] - Subscribing to
Common.Users.Messages.Events.IAllUsersPublished, Common.Users.Messages,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null at publisher queue
Common.Users.MessageHandlers.DevTest
[10] INFO NServiceBus.Unicast.UnicastBus [(null)] - Subscribing to
Common.Users.Messages.Events.IAllUsersPublished, Common.Users.Messages,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null at publisher queue
Common.Users.MessageHandlers.DevTest
INFO NServiceBus.Unicast.UnicastBus [(null)] - Common.Users.WebApp.DevTest
initialized.
WARN NServiceBus.Unicast.Transport.Msmq.MsmqTransport [(null)] - Failed raising
'transport message received' event for message with
ID=537591b0-20e2-4ab9-aabc-b635c3d0e23c\3997
System.ArgumentNullException: Value cannot be null.
Parameter name: value
at System.String.IndexOf(String value, Int32 startIndex, Int32 count,
StringComparison comparisonType)
at NServiceBus.Unicast.UnicastBus.IsInitializationMessage(TransportMessage
msg) in
d:\code\nservicebus-src\src\unicast\NServiceBus.Unicast\UnicastBus.cs:line 1211
at NServiceBus.Unicast.UnicastBus.TransportMessageReceived(Object sender,
TransportMessageReceivedEventArgs e) in
d:\code\nservicebus-src\src\unicast\NServiceBus.Unicast\UnicastBus.cs:line 1056
at System.EventHandler`1.Invoke(Object sender, TEventArgs e)
at
NServiceBus.Unicast.Transport.Msmq.MsmqTransport.OnTransportMessageReceived(Tran\
sportMessage msg) in
d:\code\nservicebus-src\src\impl\unicast\NServiceBus.Unicast.Msmq\MsmqTransport.\
cs:line 400
This last entry repeats for every message in the queue; the queue messages
remain in the queue.
So I checked out the source code IsInitializationMessage; here is the throwing
code:
private bool IsInitializationMessage(TransportMessage msg)
{
if (msg.ReturnAddress == null)
return false;
if (!msg.ReturnAddress.Contains(Address)) <<< THROWS
return false;
So it appears that UnicastBus.Address is Nothing. Not sure why this would be;
here are the NServiceBus configurations:
<MsmqTransportConfig
InputQueue="Common.Users.WebApp.DevTest"
NumberOfWorkerThreads="1"
MaxRetries="5"
ErrorQueue="Common.Users.WebApp.DevTest.Errors" />
<UnicastBusConfig>
<MessageEndpointMappings>
<add Messages="Common.Users.Messages"
Endpoint="Common.Users.MessageHandlers.DevTest" />
</MessageEndpointMappings>
</UnicastBusConfig>
On Application_Start I'm using the following code to get NServiceBus started:
Dim bus = NServiceBus.Configure.WithWeb() _
.Log4Net() _
.StructureMapBuilder() _
.XmlSerializer() _
.MsmqTransport() _
.UnicastBus().LoadMessageHandlers() _
.CreateBus()
bus.Start()
I changed the identity that the web application's app pool was using from defaultapppool to NETWORK SERVICE. On next startup the web app reported the same error. It restarted again an hour later and the problem went away and the messages were all successfully processed. I don't know if the identity change fixed it, or if there was some other change that I'm not aware of. If it happens again or I learn more I'll try to post it here.