enterprise library 3.1 - if one listener is failed then subsequent listener will be never executed - enterprise-library

I am using Msmqdistributor service of Enterprise Library 3.1 to distribute logs from various application.I have defined multiple listeners in categorySources/specialSources, but if one listener is failed than subsequent listeners will be never executed.
Following is my config code.
<specialSources>
<allEvents switchValue="Warning" name="All Events">
<listeners>
<add name="Database Listener A" />
<add name="Custom Trace Listener A" />
<add name="Custom Trace Listener B" />
</listeners>
</allEvents>
<notProcessed switchValue="Warning" name="Unprocessed Category" />
<errors switchValue="Warning" name="Logging Errors & Warnings"/>
</specialSources>
If I am specifying wrong connection string for Database Listener A then it will be failed to insert logs in database. But it also stops the jobs of next Custom Trace Listener A and Custom Trace Listener B.So here Custom Trace Listener A and Custom Trace Listener B will be never executed if Database Listener A is failed.
Anybody can help please ?
Thanks
Mitesh Patel

This behavior seems to be "by design". See the answer for Microsoft Enterprise Library 4.1 Logging Fails on Windows XP SP3.
Of course, this doesn't really help you. One workaround would be to attach one listener to a category. So for your 3 listeners you could add 3 categories. This will work but is not particularly elegant.
Since you indicate that you are using 2 custom trace listeners another approach to mitigate the issue would be to code the custom trace listeners to swallow any exceptions (not usually a good idea, though). You could also order your trace listeners from least likely to fail to most likely to fail. E.g. Database > Event Log > Flat File. In your scenario place the custom trace listeners before the database trace listener.
It is also good practice to add a trace listener to the errors category. Not sure if you have that in your app or not (but the posted config doesn't).

Related

Strange IIS/WCF Web Service Issue

Windows Server 2012 - IIS 8.x
I have a WCF web service (DLL) deployed in IIS that supports SOAP and REST over https. There is a certificate installed from Comodo for the SSL.
When I create a proxy for the service in C# apps everything works fine. Also, when I call most of the REST methods from a browser or from Postman they also work fine.
But there are a few REST methods that fail with no exception. In Chrome browser I get an error that says: "This site can't be reached." In Postman I get an error that says: "Could not get any response."
When I check the code in the WCF service I can see that the method gets called and actually executes with no exception, but nothing is returned. I've also checked the IIS logs and I don't seem to see any errors.
Here is an example of a method that works fine:
[OperationContract]
[WebGet(ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped, UriTemplate = "/GetActivityRules?agencyID={agencyID}")]
List<ActivityRule> GetActivityRules(int agencyID);
Yet, this method fails:
[OperationContract]
[WebGet(ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped, UriTemplate = "/GetActivity?agencyID={agencyID}&userID={userID}&date={date}&view={view}")]
List<Activity> GetActivity(int agencyID, int userID, string date, string view);
Has anyone experienced this before or have any ideas why this is happening or how best to troubleshoot?
UPDATE #1
I added code to the GetActivity function that writes to a log file each time its called. I can see the function executes correctly without error each time, but still there is no response. Makes me wonder if the problem is not related to WCF. I also added a trace listener to web config, but the file never gets created.
<system.diagnostics>
<sources>
<source name="System.ServiceModel"
switchValue="Information, ActivityTracing"
propagateActivity="true">
<listeners>
<add name="traceListener"
type="System.Diagnostics.XmlWriterTraceListener"
initializeData= "C:\Samadhi\TraceLog.svclog" />
</listeners>
</source>
</sources>
</system.diagnostics>
UPDATE #2
I spent a week of mind numbing searching, reading, and checking everything I possibly could with no result. I raised a support issue with Microsoft, which was escalated to one of their senior engineers. They have spent two days looking into the problem with still no solution. They tell me they have never seen this before!
I tried using your code and testing it locally, and it looked like everything was working fine. Even if method 2 contains multiple parameters, WCF can receive them. I think the problem is somewhere else. For example, if the data volume transfer is too large, please try to configure the following code in the binding.
<binding name="mybinding" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" sendTimeout="00:10:00" receiveTimeout="00:10:00">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" />
Or you can construct the collection return directly to eliminate problems with backend data queries.
to enable wcf tracing, you have to create a source configuration for System.ServiceModel. This should trace the service serialization:
<system.diagnostics>
<sources>
<source name="System.ServiceModel" switchValue="Verbose" propagateActivity="true">
<listeners>
<add name="svc" />
</listeners>
</source>
</sources>
<sharedListeners>
<add name="svc" type="System.Diagnostics.XmlWriterTraceListener" traceOutputOptions="DateTime" initializeData="c:\trace.svclog" />
</sharedListeners>
<trace autoflush="true" indentsize="4">
<listeners>
<add name="svc" />
<remove name="Default" />
</listeners>
</trace>
<system.diagnostics>
How frustrating software development can be. I swear I'm going to need hair replacement therapy soon. I finally found what was causing the issue, and as is most often the case, it boils down to my programming error. The frustrating part is when you have no error message, or when a framework throws a generic error that gives no clue as to what's wrong.
The issue came down to the fact that WCF was unable to return the JSON result - unable to parse the list of objects into JSON. This happened because an uninitialised date value was outside the allowed min and max values. The net result was no response from the server, not even an error code. When calling the same method using SOAP, the XML parsed fine - only the REST call was failing.
I initially had problems setting up WCF trace. For some reason it was causing the service to stop working. And because it was a production server, I had only limited time frames to work with when making config changes. Finally after seeing the JSON error message I knew what to do to fix the problem.

Sitecore 8.1 error: "No session Id managers were found to manage the session Id for the current request"

I'm attempting to get a basic layout up and running in Sitecore 8.1, and I've hit an error about which I can find very little information. When attempting to view any page (even the backend interface or connecting from Sitecore Rocks), I get the message "No session Id managers were found to manage the session Id for the current request."
Some Googling suggests that this has to do with some issues with the out-of-box session provider and recommends swapping it out for keeping the sessions in Mongo. Sitecore's documentation provides a description of this, both for shared and private sessions. I've attempted to implement those but continue to receive the same error.
Here's my code as it stands now:
App_Config/Include/MongoSessionProvider.config
<?xml version="1.0"?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<tracking>
<sharedSessionState>
<providers>
<clear/>
<add name="mongo" type="Sitecore.SessionProvider.MongoDB.MongoSessionProvider, Sitecore.SessionProvider.MongoDB" connectionString="session" pollingInterval="2" compression="true" sessionType="shared"/>
</providers>
</sharedSessionState>
</tracking>
</sitecore>
</configuration>
App_Config/Include/ConnectionStrings.config (excerpt)
<add name="session" connectionString="mongodb://localhost/sharedsession" />
Web.config (excerpt)
<sessionState mode="Custom" cookieless="false" timeout="20" sessionIDManagerType="Sitecore.FXM.SessionManagement.ConditionalSessionIdManager" customProvider="mongo">
<providers>
<add name="mongo" type="Sitecore.SessionProvider.MongoDB.MongoSessionStateProvider, Sitecore.SessionProvider.MongoDB" sessionType="Standard" connectionStringName="session" pollingInterval="2" compression="true" />
<add name="mssql" type="Sitecore.SessionProvider.Sql.SqlSessionStateProvider, Sitecore.SessionProvider.Sql" sessionType="Standard" connectionStringName="session" pollingInterval="2" compression="true" />
</providers>
</sessionState>
Note that this is on my local development machine. I have Mongo running (and confirmed its connection to Sitecore), and I created both the session and sharedsession databases in it using use session and use sharedsession, which I understand to be the way to create DBs in Mongo.
Am I missing something here? Or does the error simply not mean what I think it means?
The message you are seeing is not supposed to be an error, it is rather a log warning. It is related to retrieving the configuration of the Session ID Manager rather that to the configuration of the session itself.
Why this warning normally appears
In the Sitecore.config under <pipelines> there's the getSessionIdManager pipeline defined.
<getSessionIdManager>
</getSessionIdManager>
In the Sitecore.FXM.config, there is a processor configured for this pipeline:
<getSessionIdManager>
<processor type="Sitecore.FXM.Pipelines.ChooseSessionIdManager.FXMSessionIdManagerProcessor, Sitecore.FXM" />
</getSessionIdManager>
This pipeline allows to dynamically select a Session ID Manager for the request. In the default Sitecore configuration, a non-default Session ID Manager will be used only for requests with explicit sessionId URL parameter, i.e. for FXM requests only.
For all other requests, no Session ID Manager will be explicitly selected, and the default System.Web.SessionState.SessionIDManager will be used; this is reflected in the warning message you're seeing. There is nothing wrong with this situation per se, this is by default and by design.
Seeing the message as an error on every page request
This definitely sounds like a defect to me. This message is supposed to be logged once per application lifetime instead of being thrown as an exception on every page.
You should report this to Sitecore support.
An attempt to fix
I cannot debug your system, so I have to do this blindfolded. I would try to create you own Session ID Manager selector:
public class CustomSessionIdManagerProcessor
{
public void Process(GetSessionIdManagerArgs args)
{
if(args.SessionIdManager == null)
{
args.SessionIdManager = new System.Web.SessionState.SessionIDManager();
}
}
}
Configure it as the last processor in the getSessionIdManager pipeline. This will make sure that there is always an explicitly selected Session ID Manager and should hopefully prevent the error from happening.
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<pipelines>
<getSessionIdManager>
<processor type="YourNamespace.CustomSessionIdManagerProcessor, YourAssembly" />
</getSessionIdManager>
</pipelines>
</sitecore>
</configuration>
In case it helps anyone else, we were running into this issue as well after upgrading to Sitecore 8.1 rev. 151003.
In our particular case the issue was with a namespace change in this line in the Web.config:
<sessionState mode="InProc" cookieless="false" timeout="20"
sessionIDManagerType="Sitecore.FXM.SessionManagement.ConditionalSessionIdManager">
That should be the following:
<sessionState mode="InProc" cookieless="false" timeout="20"
sessionIDManagerType="Sitecore.SessionManagement.ConditionalSessionIdManager">
It might have been something we missed in the upgrade guide, but we finall found it after pulling down the a copy of Sitecore 8.1 rev. 151003.zip from the downloads page.

Spring Batch Integration, Email to be sent out in case of JobInstanceAlreadyCompleteException

I would like to put a hook somewhere in the following code/config to be able to spot a JobInstanceAlreadyCompleteException and then email the production support team that this occurred.
I have tried a JobExecutionListener#beforeJob() method in Spring Batch, but the JobInstanceAlreadyCompleteException is occurring before job execution.
I am using this Spring Batch Integration configuration from the documentation:
<int:channel id="inboundFileChannel"/>
<int:channel id="outboundJobRequestChannel"/>
<int:channel id="jobLaunchReplyChannel"/>
<int-file:inbound-channel-adapter id="filePoller"
channel="inboundFileChannel"
directory="file:/tmp/myfiles/"
filename-pattern="*.csv">
<int:poller fixed-rate="1000"/>
</int-file:inbound-channel-adapter>
<int:transformer input-channel="inboundFileChannel"
output-channel="outboundJobRequestChannel">
<bean class="io.spring.sbi.FileMessageToJobRequest">
<property name="job" ref="personJob"/>
<property name="fileParameterName" value="input.file.name"/>
</bean>
</int:transformer>
I want to handle JobInstanceAlreadyCompleteException in case the same CSV file name appears as the job parameter. Do I extend org.springframework.integration.handler.LoggingHandler?
I notice that class is reporting the error:
ERROR org.springframework.integration.handler.LoggingHandler - org.springframework.messaging.MessageHandlingException: org.springframework.batch.core.repository.JobInstanceAlreadyCompleteException: A job instance already exists and is complete for parameters={input.file.name=C:\Users\csv\file2015.csv}. If you want to run this job again, change the parameters.
The ERROR org.springframework.integration.handler.LoggingHandler is done from the default errorChannel which is reached from the <poller> on your <int-file:inbound-channel-adapter>.
So, to handle it manually your just need to specify your own error-channel there a go ahead with email sending:
<int-file:inbound-channel-adapter>
<int:poller fixed-rate="1000" error-channel="sendErrorToEmailChannel"/>
</int-file:inbound-channel-adapter>
<int-mail:outbound-channel-adapter id="sendErrorToEmailChannel"/>
Of course, you will have to do some ErrorMessage transformation before sending ti over e-mail, but that is already details of the target business logic implementation.

jboss connection pool doesn't handle errors gracefully

I'm using jboss 5.0.1 with multiple data sources configured.
It seems that on startup, if one of those is configured incorrectly, jboss throws an exception and refuses to start.
I would like to know if it's possible to configure jboss to be resilient to these kind of problems.
You can configure the connections in the xml file which holds the connection parameters/mapping. In my case, i am using a microsoft sql server as the datasource, so i have to use the mssql-ds.xml file (inside the server/deploy directory) to specify:
<?xml version="1.0" encoding="UTF-8"?>
<datasources>
<local-tx-datasource>
<jndi-name>myTestServer</jndi-name>
<connection-url>jdbc:sqlserver://xxx.xxx.xxx.xxx:1433;databaseName=MyDB</connection-url>
<driver-class>com.microsoft.sqlserver.jdbc.SQLServerDriver</driver-class>
<user-name>test</user-name>
<password>abc123</password>
<min-pool-size>10</min-pool-size>
<max-pool-size>25</max-pool-size>
<!-- sql to call when connection is created -->
<new-connection-sql>select getdate()</new-connection-sql>
<!-- -->
<!-- sql to call on an existing pooled connection when it is obtained from pool
This will be run before a managed connection is removed from the pool
for use by a client -->
<check-valid-connection-sql>select getdate()</check-valid-connection-sql>
</local-tx-datasource>
</datasources>
This helps control the connections in the pool, and should stop dodgy deadlocks. I'm not entirely sure whether this will test the current transaction level on the connection in question, so if you want to make absolutely sure, you can try: <check-valid-connection-sql>IF ##TRANCOUNT > 0 raiserror ('%s',18,1,'Open Transactions Discovered')</check-valid-connection-sql> This will give you an explicit SQLException to handle.
But if you are getting an error on startup, it would be very useful to see what those errors are.

WCF Web Service Metadata Publishing Disabled Error

I modified my web.config to add a custom binding in order to increase the buffer and message size, and it seems like in creating the service element explicitly, it has somehow broken the reference to my behavior element.
When I try to run my web service from VS using the WCF Test Client, or I go to the service page, I get the error:
Metadata publishing for this service is currently disabled.
I've compared my web.config to a few different sources on this and everything seems to match. I've no idea what the issue is.
Here is the System.serviceModel element:
<system.serviceModel>
<services>
<service name="BIMIntegrationWS.BIMIntegrationService" behaviorConfiguration="metadataBehavior">
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<endpoint address="http://localhost:1895/BIMIntegrationService.svc"
binding="customBinding" bindingConfiguration="customBinding0"
contract="BIMIntegrationWS.IBIMIntegrationService"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="metadataBehavior">
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<customBinding>
<binding name="customBinding0">
<binaryMessageEncoding />
<httpTransport maxReceivedMessageSize="262064"
maxBufferSize="262064"
maxBufferPoolSize="262064" />
</binding>
</customBinding>
</bindings>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="true"/>
It almost seems like either the web service page is not finding the element. I don't get an error complaining that the target behaviorConfiguration doesn't exist, or anything like that, just that Metadata publishing is not enabled.
Any help would be greatly appreciated.
Thanks.
I think i've "fixed" the issue. More coming later.
EDIT:
In order to "fix" my issue, I basically added a new WCF service to my application, and had it implement my previous interface, I then copied all the code from my original service and when I tweaked the .config file (to look pretty much like the one posted in the question), everything worked fine.
Ofcourse, I know, like we all know, that there is no magic here, that there must be some discrepancy. This is when I noticed/remembered, that after I had created my original service, called "BIMIntegrationService.svc", I had decided that this was too long of a name, so I renamed/refactored my class to "BIMIntegrationWS". Doing this, however, does not change the name of the service file (and therefore the name of the file in the http:// address).
Long story short, I made 2 changes to my .config and everything worked:
1) I changed:
<service name="BIMIntegrationWS.BIMIntegrationService" behaviorConfiguration="metadataBehavior">
to
<service name="BIMIntegrationWS.BIMIntegrationWS" behaviorConfiguration="metadataBehavior">
After running the service like this, I got an error (a helpful one this time) complaining that if multipleSiteBindings was enabled, the endpoint address had to be relative. So:
2) I set that to false (because I don't remember why it was in there in the first place) and everything worked fine.
I guess I should have taken a hint when it seemed like my web service was not using my "service" element at all. :\
EDIT 2:
Actually, you can see in my second comment, in the original question, that the auto-generated tag was pointing to: , as opposed to "BIMIntegrationService".
That should have given it away.
I doubt many other people will have this same issue, but just in case.
I've had the same trouble; I've gotten everything configured correctly (even copied the code from a previous service I have running) and yet no change on allowing the service to expose metadata. yet, if I make a spelling error, parse error, etc. to the app.config I'm given exceptions telling me to correct the problem (which tells me the service is reading the config, just disregarding it.
I was able to bypass it by generating the config settings in the host application:
System.ServiceModel.Description.ServiceMetadataBehavior smb = new System.ServiceModel.Description.ServiceMetadataBehavior();
smb.HttpGetEnabled = true;
ServiceBase host = new Servicebase(typeof(MyService), new Uri("http://localhost:1234/"));
host.Description.Behaviors.Add(smb);
host.Open();
...
host.Close();
Basically allow the code to override and push the config file changes i wanted applied. I know it's not ideal, but I was exposing the service through a windows service which made this do-able. if you do get your problem resolved, please pass along the solution though as I'd be curious to know why (at least in yours, if not both our cases) it's failing.