Spring Batch: Tasklet with Task-Executor - concurrency

I have a problem understanding something. I am using Spring-Batch, configured tasklet with a task-executor. Few configuration on task-executor works fine, other configuration seems that the tasklets are not executed. I don't understand, why few of them let Spring-Batch work, but others keep it away from work. I hope someone will bring light into the dark.
What works is e.g.
<task:executor id="myExecutor" pool-size="10" queue-capacity="1000000" />
<task:executor id="myExecutor" pool-size="10-50" queue-capacity="10000000" />
What doesn't work more and it looks like the threads doesn't start or got interrupt or not picked up:
<task:executor id="myExecutor" pool-size="5-10" queue-capacity="10000000" />
<task:executor id="myExecutor" pool-size="5-10" queue-capacity="10" />
<task:executor id="myExecutor" pool-size="5-50" queue-capacity="10000000" />
<task:executor id="myExecutor" pool-size="10-50" queue-capacity="1" />
The job is something like:
<batch:job id="myJob">
<batch:decision ... />
<batch:step id="myStep">
<batch:tasklet task-executor="myExecutor">
<batch:chunk reader="..." processor="..." writer="..." commit-interval="1000" />
</batch:tasklet>
</batch:step>
</batch:job>
Maybe I am missing few basic knowledge about task:executor. How do I know, what are good values for pool-size, queue-capacityor similar. I guess when the configuration works fine on my system I don`t have that feeling to have guarantee that it works anywhere. What happens in the background, when it seems the job started, but then nothing happens more. I also can see under windows performance task manager, that the job doesn't do anything more.
Thanks for a clear explanation.

Related

Web Service Error 400 - Bad Request

I have a perplexing issue. I have Web Service A (henceforth WSA), a 3.5 .Net WCF, which I have added a call to Web Service B (henceforth WSB) which is a 3.5 .Net ASMX. When running WSA in the client (SOAPUI or WCFStorm), the WSB call times out per the client timeout setting.
In the VS event viewer I can see that the call to WSB immediately throws two error 400s:
Exception thrown: 'System.Net.WebException' in System.dll ("The remote
server returned an error: (400) Bad Request."). Exception thrown:
'System.Net.WebException' in System.dll ("The remote server returned
an error: (400) Bad Request.")
No reason is given. What is just as puzzling to me is the error doesn't go to my catch. When I debug and I hit the line of code that calls WSB, it's like a reset. No further code gets executed and no error is thrown by my WSA.
If I call WSB directly, it works. So nothing is wrong with WSB. At suggestion of a coworker, I took the code specific to my change and put it in a stand-alone service. I literally C&P the code and configs setting specific to me and adjust namespaces and class names. Lo and behold it works. My stand-alone web service called WSB just fine and get the data I expect.
A coworker and I checked the logs (IIS log for the service and the HTTPERR log) on the IIS server that WSB resides on to see if there was any mention of the 400 error. We found none.
So we are kind of perplexed at this point. The only thing we can think of is perhaps something in the web config might be interfering but have no idea what it could be.
If you have any suggestions of where else to look that would be helpful.
And it would be nice to know why it isn't falling into my error handler.
Thanks.
Update: It was requested I add config and code. I don't think it will help honestly and it is pretty straightforward. I can't put the real code due to company reasons but it is basically this:
In web config:
<configuration>
<appSettings>
<add key="endpointUrl" value = "someurl" />
</appSettings>
.
.
.
<applicationSettings>
<MyService.Properties.Settings>
<setting name="MyService_TheirService"
serializeAs="String">
<value>someurl</value>
</setting>
</MyService.Properties.Settings>
</applicationSettings>
Even though the data is super small I did try making large reader settings and such:
<binding name="CustomHtttpBinding" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" closeTimeout="01:50:00" openTimeout="01:50:00" sendTimeout="01:50:00" receiveTimeout="01:50:00" >
<readerQuotas maxDepth="128"
maxStringContentLength="8388608"
maxArrayLength="2147483646"
maxBytesPerRead="4096"
maxNameTableCharCount="16384" />
</binding>
Code:
using MyService.TheirService
.
.
.
var theirURL = ConfigurationManager.AppSettings["endpointUrl"];
var oSvc = new TheirServiceObject
{
Url = theirURL
};
int numberIneed = oSvc.SomeMethod();
That last line is where it throws the 400.
UPDATE 2:
A colleague show me how to use Fiddler. And I can now see that the request to WSB is absolute garbage.
xڭ s 6 mr!!u \ .3 5'3 G QOH>Iп kX M3 ~vY ) X e Z
w ~ :jv -ݴwڽHb Yqv A :(Q Z; >9W O0g 6 .ɖVlU Ţ 8Z
< ( t eSv U]r R $N \
Some odd encoding? At least it's another clue.
Wanted to let you know this problem was solved. Another Dev that had worked on this service before but no longer just happened to walk by and I said "Hey! Look at this!"
They saw the garbage request data and said "That looks like compression. Look up compression in the project."
Turn out there was a custom compression component that was compressing the outgoing data of the service and you needed to add 2 lines of code to decompress. After adding those lines to the top of my method everything immediately worked.
The lesson here is if your project is doing some weird stuff that defies reason, try and find as many people as you can that worked on it before even if they aren't working on it anymore.

ColdSpring IsLazyInit isn't boolean?

Anyone ever seen this error with ColdSpring?
The ISLAZYINIT argument passed to the createBeanDefinition function is not of type boolean.
This is happening after restarting the CF service, and when it's attempting to do something like this in onApplicationStart
beanFactory = createObject("coldspring.beans.DefaultXmlBeanFactory").init(defaultProperties=stuCsConfig);
beanFactory.loadBeans(expandPath("/shared/config/coldspring-services.xml"));
The contents of that coldspring-services.xml file looks something like:
<bean id="PageHeader" class="path.to.PageHeader" singleton="true" lazy-init="false">
<constructor-arg name="fooBar">
<value>${fooBar}</value>
</constructor-arg>
</bean>
for a few dozen similarly constructed beans, some set to lazy-init=false, some set to lazy-init=true.
Nothing particularly obvious in the code has changed recently, and I'm wondering if it's possibly a problem with the Java JVM, or something that could be set in CF Admin such as caching. Anyone seen this before or has a suggestion?
The problem seemed to be this: on that server Java had been upgraded from 7 to 8. It hadn't worked, so it was rolled back to Java 7. However it seems that something was changed by the upgrade that hadn't been reverted when it was changed back to Java 7.
The fix was to completely uninstall Java and re-install v7 from start, which seemed to fix it.

Two flows inside one .mflow file

I would like to ask how can I start another flow using quartz.
Starting each flow seperately (one is trigered with IMAP and second with Quartz) works ok, but I would like to have both of them in same file if possible, or at least in same project. I don't know what is good practice for this so I let you decide.
So, Flow1 starts with IMAP and do its job with mail (original) and then goes on to other subflows.
Flow2 starts with quartz and do its job (the one I would like to add)
Both flows have same variables and have similar job but don't have to be sinchronized of course.
Now, how can I achieve this?
I tried this:
<flow name="Flow1" doc:name="Flow1">
<imaps:inbound-endpoint doc:name="IMAP"
host="imap.gmail.com" port="993" responseTimeout="10000"
........
</flow>
<flow name="Flow2" doc:name="Flow2">
<quartz:outbound-endpoint jobName="FlowStarter" repeatInterval="10000" responseTimeout="10000" doc:name="Quartz">
<quartz:event-generator-job groupName="QuartzGenGroup" jobGroupName="QuartzGenGroup">
<quartz:payload>wwqda</quartz:payload>
</quartz:event-generator-job>
</quartz:outbound-endpoint>
<logger message="Quartz started at #[server.dateTime.toCalendar().toString()] #[payload]" level="INFO" doc:name="Logger"/>
</flow>
When I started this, Flow2 never gave any output.
I am using Mule Studio 3.5.0
Thank you!
In the Flow 2 use quartz:inbound-endpoint instead of quartz:outbound-endpoint. Outbound endpoint does not trigger workflow itself. It requires an additional incoming event.
Look at http://2rdscreenretargeting.blogspot.ru/2012/12/how-to-schedule-jobs-using-mule-studio.html for details on Quartz usage in Mule.

Sitecore context in HttpHandler

I have HttpTaskAsyncHandler in my sitecore solution and i call it I have sutup IngnoreUrlPrefix and etc.
By some reason i can't get access to SC.Context.Database Database is null in ProcessRequestAsync(HttpContext context) method,
it looks like I don't access to Sitecore context in HttpHandler.
How to resolve it ?
Thanks.
You wont be able to access Sitecore Context (Database or Item) in the Handler. We have confirmed this with Sitecore Support for our task.
The best way is Implement a Processor in the Request pipeline begin.
How to Implement
Inherit HttpRequestProcessor in your class found in (using Sitecore.Pipelines.HttpRequest;)
and add that Processor after SiteResolver in < httpRequestBegin >
<processor type="Sitecore.Pipelines.HttpRequest.SiteResolver, Sitecore.Kernel" />
<!-- Custom Module -->
<processor type="SND641.Customization.RobotsModule, SND641" />
If you choose to ignore your script file (by using IgnoreUrlPrefix), then you it will not be processed by Sitecore's request pipeline and thus will not have a Sitecore context.
I think you can solve it by removing your url prefix from IgnoreUrlPrefix and make sure the file extension of your handler is added to the allowed extensions parameter of the FilterUrlExtensions pipeline processor:
<processor type="Sitecore.Pipelines.HttpRequest.FilterUrlExtensions, Sitecore.Kernel">
<param desc="Allowed extensions (comma separated)">aspx</param>
</processor>
This way you can call your script and still have Sitecore process all the pipelines.
You can get context without pipeline. Along with web.config handler definition, you will need to add under customHandler. It helps in getting sitecore context. E.g
<customHandlers>
<handler trigger="blogfeed.xml" handler="blogfeed.xml" />
</customHandlers>
I'm sorry if I'm not getting exactly what you are trying to do. But by working with handlers I did have issues that my code was not able to access the sitecore object even when I updated the web.config and
I noticed that my handler was like this:
public class GetHandler: IHttpHandler
{
...
}
by adding the System.web.SessionState.IrequiresSessionStatem, like this:
public class GetHandler : IHttpHandler, System.Web.SessionState.IRequiresSessionState
{....}
then everything started to work and I was able to get items from sitecore without issues:
Public void ProcessRequest(HttpContext context)
{
Database webdb = Factory.GetDatabase("web");
}
previous my change the webdb was coming with nothing and the code was coming back with "Command "Sitecore.Database" is not valid"
after that changes, as I said, everything worked for me.
I hope this helps and adds some value to the existing answers.
regards,

NullReferenceException in XSockets.DevServer.DebugInstance()

I'm playing around with XSockets.NET, and I've spent way too much time debugging what should be a simple problem. I'm using the standard templates that come with XSockets, which create a project called XSockets.DevServer, and a class within that project called DebugInstance. When I host this DebugInstance class within my web project, all seems to work as expected. However, when I try to host it within the XSockets.Debug.Console project, or when I try to get it to run on my production IIS instance, I get a NullReferenceException in the code below:
[ImportOne(typeof(IXBaseServerContainer))]
public IXBaseServerContainer wss { get; set; }
public DebugInstance()
{
try
{
Debug.AutoFlush = true;
this.ComposeMe();
// NullReferenceException on the next line - wss apparently never gets set.
wss.OnServersStarted += wss_OnServersStarted;
wss.OnServerClientConnection += wss_OnServerClientConnection;
wss.OnServerClientDisconnection += wss_OnServerClientDisconnection;
wss.OnError += wss_OnError;
wss.OnIncommingTextData += wss_OnIncommingTextData;
wss.OnOutgoingText += wss_OnOutgoingText;
wss.OnServersStopped += wss_OnServersStopped;
wss.StartServers();
}
catch (Exception ex)
{
Debug.WriteLine("Exception while starting server: " + ex);
Debug.WriteLine("Press enter to quit");
}
}
Clearly the problem is happening within this.ComposeMe(), but there's no troubleshooting information, and since XSockets isn't apparently open-sourced, I haven't been able to step through the code to figure out where the problem is.
EDIT: To be clear, I know what a NullReferenceException is. In this case its immediate cause is the fact that wss is null. What I want to know is its proximate cause, i.e., why ComposeMe() doesn’t assign it, even though that's what it's apparently supposed to be doing. Apparently the homegrown IOC that XSockets is using to support its plugin architecture is supposed to find an instance of IXBaseServerContainer, but it's apparently not - and I have no idea why. And not having the source, I'm not even sure what the candidates for IXBaseServerContainer are.
EDIT 2012-11-06: Here's what the appSettings element of my app.config looks like:
<appSettings>
<add key="XSocketServerStartport" value="4502"/>
<add key="UsePolicyServer" value="true"/>
<add key="XSockets.PluginCatalog" value="XSockets\XSocketServerPlugins\"/>
<add key="XSockets.PluginFilter" value="*.dll"/>
<add key="XMessageInterceptorsEnabled" value="false"/>
<add key="XErrorInterceptorsEnabled" value="false"/>
<add key="XConnectionInterceptorsEnabled" value="false"/>
<add key="XHandshakeInterceptorsEnabled" value="false"/>
<add key="XSocketLogPath" value="XSockets\XSocketServerPlugins\Log"/>
<add key="XBufferSize" value="8192"/>
</appSettings>
I've got all the files mentioned below in both my $(ProjectDir)\XSockets\XSocketServerPlugins\ and my $(TargetDir)\XSockets\XSocketServerPlugins\ folders, e.g.:
10/29/2012 09:53 AM 15,872 XSockets.Core.Communication.dll
10/29/2012 09:53 AM 70,656 XSockets.Core.dll
10/29/2012 09:53 AM 8,192 XSockets.DevelopmentServer.dll
10/29/2012 09:53 AM 11,776 XSockets.Extensibility.Handlers.dll
10/29/2012 09:53 AM 10,240 XSockets.Extensibility.Interceptors.dll
10/29/2012 09:53 AM 23,040 XSockets.External.dll
10/29/2012 09:53 AM 24,064 XSockets.Protocol.dll
10/29/2012 09:53 AM 39,424 XSockets.Server.dll
11/05/2012 05:37 PM 12,288 XSockets.WebRTC.Prototype.Shared.Handlers.dll
Any thoughts?
Ken,
When the plugin framework of XSockets.NET dont find any "plugins" there is nothing to Compose. I think the reason of this is that you don't have the "plugins" deployed in the IIS Production instance of yours?
You will need to add the following elements to your appSettings section of the config file(web.config)
<add key="XSockets.PluginCatalog" value="XSockets\XSocketServerPlugns\" />
<add key="XSockets.PluginFilter" value="*.dll" />
In "my case" i have the XSockets.NET plugins (protocols, handlers/controllers) inside the
/XSockets/XSocketServerPlugns folder in my Website.
you should have the following plugins ( .dll's) in that folder
XSockets.Core.Communication
XSockets.Core
XSockets.Extensibility.Handlers
XSockets.Extensibility.Interceptors
Xsockets.External
XSockets.Protocol
XSockets.Server
XSockets.DevelopmentServer **
** This is the project/class library that contains the server of yours. ( i.e the DebugInstance)
If you want to configure the server , you will need to create a configuration loader class see this url for info http://xsockets.net/api/net-c/creating-custom-configuration-plugin , or just shoot an email to contact#xsockets.net and we will help you out.
If you need further assistance, just let me know.
Kind regards
First of all, if you are running a Console Application switch to .NET 4 instead of the default .NET 4 client profile (if not done already).
Second. We will provide a better way of knowing which references to add to the project starting the server.
Meanwhile you should be able to run this in the Package Manager Console to see what refs are needed
(Get-Project XSocketHandler).Object.References | Where-Object {$_.CopyLocal -eq $true}
You have my email, so please contact me and we can have a skype meeting or something to talk more about it.
Regards
Uffe, Team XSockets