Missing messages usingSpring Integration amqp:outbound-channel-adapter on RabbitMQ - spring-integration

On Publishing the message to Rabbit MQ Exchange, few of the messages are getting lost. For example, posted 10 messages only five got delivered to the binded queue and the rest 5 messages are lost. Please advice.
Below is Spring XML configuration for connection
<bean id="cachingConnectionFactory" class="org.springframework.amqp.rabbit.connection.CachingConnectionFactory" destroy-method="destroy">
<property name="addresses" value="example.com:8080"/>
<property name="username" value="guest" />
<property name="password" value="guest" />
<property name="virtualHost" value="guest-app" />
<property name="connectionTimeout" value="1000"/>
<property name="cacheMode" value="#{T(org.springframework.amqp.rabbit.connection.CachingConnectionFactory.CacheMode).CONNECTION}"/>
<property name="channelCacheSize" value="6000"/>
<property name="channelCheckoutTimeout" value="60000"/>
<property name="requestedHeartBeat" value="30"/>
<property name="publisherConfirms" value="true"/>
<property name="publisherReturns" value="true"/>
</bean>
Below is Rabbit Template Config
<rabbit:template id="amqpTemplate" connection-factory="cachingConnectionFactory" mandatory="true" retry-template="retryTemplate" />
<bean id="retryTemplate" class="org.springframework.retry.support.RetryTemplate">
<property name="backOffPolicy">
<bean class="org.springframework.retry.backoff.ExponentialBackOffPolicy">
<property name="initialInterval" value="500" />
<property name="multiplier" value="10.0" />
<property name="maxInterval" value="10000" />
</bean>
</property>
</bean>
<rabbit:admin connection-factory="cachingConnectionFactory" />
Below is for Publishing message
int:chain input-channel="output">
<int:header-enricher>
<int:header name="amqp_deliveryMode" value="PERSISTENT" type="org.springframework.amqp.core.MessageDeliveryMode"/>
</int:header-enricher>
<int-amqp:outbound-channel-adapter id="outboundAmqp" amqp-template="amqpTemplate" exchange-name-expression="headers['exchange']" routing-key-expression="headers['routingKey']" mapped-request-headers="*" confirm-correlation-expression="payload" confirm-ack-channel="msgResponse" confirm-nack-channel="msgResponse" return-channel="msgResponse"/>

Related

How to add default association data to Sharepoint Workflow without Association Form

I would like to know how to add default association data to Sharepoint Workflow developed in Visual studio, without any Association Form.
The problem is that i have 2 subscriptions to different lists for the same workflow, and i would like to add different default parameters values to each subscription.
Is it possible to do it directly in the Elements.xml file?
My current XML file look so:
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Module Name="Workflow" Url="wfsvc/c7f7e1db60fe427084c8b9f1720b613e">
<File Url="Workflow.xaml" Type="GhostableInLibrary" Path="Workflow\Workflow.xaml" DoGUIDFixUp="TRUE">
<Property Name="ContentType" Value="WorkflowServiceDefinition" />
<Property Name="Libreria" Value="List1" />
<Property Name="isReusable" Value="true" />
<Property Name="RequiresInitiationForm" Value="False" />
<Property Name="RequiresAssociationForm" Value="False" />
<Property Name="WSPublishState" Value="3" />
<Property Name="WSDisplayName" Value="Workflow" />
<Property Name="WSDescription" Value="Description" />
<Property Name="RestrictToType" Value="List" />
<Property Name="RestrictToScope" Value="{$ListId:List1;}" />
<Property Name="InitiationUrl" Value="_layouts/15/Pages/WorkflowRedirect.aspx" />
</File>
<File Url="WorkflowStartAssociation" Path="Workflow\WorkflowStartAssociation" Type="GhostableInLibrary">
<Property Name="WSDisplayName" Value="Workflow" />
<Property Name="ContentType" Value="WorkflowServiceSubscription" />
<Property Name="WSPublishState" Value="3" />
<Property Name="WSEventType" Value="WorkflowStart" />
<Property Name="WSEnabled" Value="true" />
<Property Name="WSGUID" Value="88ae7a57-4a2c-4fa5-8488-71e6f504002f" />
<Property Name="WSEventSourceGUID" Value="{$ListId:List1;}" />
<Property Name="Microsoft.SharePoint.ActivationProperties.ListId" Value="{$ListId:List1;}" />
<Property Name="HistoryListId" Value="{$ListId:Lists/Workflow History;}" />
<Property Name="StatusColumnCreated" Value="1" />
</File>
</Module>
<Module Name="Workflow" Url="wfsvc/8EF78D6856824F36B1EC2014E89413B1">
<File Url="Workflow.xaml" Type="GhostableInLibrary" Path="Workflow\Workflow.xaml" DoGUIDFixUp="TRUE">
<Property Name="ContentType" Value="WorkflowServiceDefinition" />
<Property Name="Libreria" Value="List2" />
<Property Name="isReusable" Value="true" />
<Property Name="RequiresInitiationForm" Value="False" />
<Property Name="RequiresAssociationForm" Value="False" />
<Property Name="WSPublishState" Value="3" />
<Property Name="WSDisplayName" Value="Workflow" />
<Property Name="WSDescription" Value="Description" />
<Property Name="RestrictToType" Value="List" />
<Property Name="RestrictToScope" Value="{$ListId:List2;}" />
<Property Name="InitiationUrl" Value="_layouts/15/Pages/WorkflowRedirect.aspx" />
</File>
<File Url="WorkflowStartAssociation" Path="Workflow\WorkflowStartAssociation" Type="GhostableInLibrary">
<Property Name="WSDisplayName" Value="Workflow" />
<Property Name="ContentType" Value="WorkflowServiceSubscription" />
<Property Name="WSPublishState" Value="3" />
<Property Name="WSEventType" Value="WorkflowStart" />
<Property Name="WSEnabled" Value="true" />
<Property Name="WSGUID" Value="B9DAA949-99BD-46C0-9942-3D74F6CCDAD1" />
<Property Name="WSEventSourceGUID" Value="{$ListId:List2;}" />
<Property Name="Microsoft.SharePoint.ActivationProperties.ListId" Value="{$ListId:List2;}" />
<Property Name="HistoryListId" Value="{$ListId:Lists/Workflow History;}" />
<Property Name="StatusColumnCreated" Value="1" />
</File>
</Module>
<ListInstance FeatureId="{2c63df2b-ceab-42c6-aeff-b3968162d4b1}"
TemplateType="4501"
Title="wfsvc"
Description="This list instance is used by SharePoint to keep track of workflows. Do not modify."
Url="wfsvc"
RootWebOnly="FALSE" />
</Elements>
You can add any property in the WorkflowStartAssociation and then read them in your Workflow using the GetConfigurationValue activity

CQWP - displaying Author, Check Out To, etc... from multiple libraries

I have a CQWP that I created which lists the document icon, title, Author, Checked Out To, and Last Modified. Everything displays fine if I point it at a single document library but when I point it to the subsite, in order to see documents from all libraries, I get the icon and title but nothing else. What am I missing? Here is my code from the ItemStyle.xsl:
<xsl:if test="count(preceding-sibling::*)=0">
<div style="float:left; width:32px;"> </div>
<div style="float:left; width:15%; padding-right:15px;">Name</div>
<div style="float:left; width:10%; padding-right:15px;">Created By</div>
<div style="float:left; width:10%; padding-right:15px;">Checked Out</div>
<div style="float:left;">Last Modified</div>
</xsl:if>
<div class="item link-item">
<xsl:if test="string-length(#DocumentIconImageUrl) != 0">
<div class="image-area-left" style="width:25px;">
<img class="image" src="{#DocumentIconImageUrl}" title="" />
</div>
</xsl:if>
<div class="link-item">
<xsl:if test="count(preceding-sibling::*)=0">
</xsl:if>
<xsl:call-template name="OuterTemplate.CallPresenceStatusIconTemplate"/>
<div style="float:left; width:15%; padding-right:15px;">
<a href="{$SafeLinkUrl}" title="{#LinkToolTip}">
<xsl:if test="$ItemsHaveStreams = 'True'">
<xsl:attribute name="onclick">
<xsl:value-of select="#OnClickForWebRendering"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="$ItemsHaveStreams != 'True' and #OpenInNewWindow = 'True'">
<xsl:attribute name="onclick">
<xsl:value-of disable-output-escaping="yes" select="$OnClickTargetAttribute"/>
</xsl:attribute>
</xsl:if>
<xsl:value-of select="$DisplayTitle"/>
</a>
</div>
<div style="float:left; width:10%; padding-right:15px;">
<xsl:value-of select="#Author" />
</div>
<div style="float:left; width:10%; padding-right:15px;">
<xsl:choose>
<xsl:when test="string-length(#CheckoutUser) = 0">
Checked In
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="#CheckoutUser" />
</xsl:otherwise>
</xsl:choose>
</div>
<div style="float:left;"><xsl:value-of select="ddwrt:FormatDate(#Modified, 1033, 2)" /></div>
</div>
</div>
here is the code from my CQWP:
<metaData>
<type name="Microsoft.SharePoint.Publishing.WebControls.ContentByQueryWebPart, Microsoft.SharePoint.Publishing, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />
<importErrorMessage>Cannot import this Web Part.</importErrorMessage>
</metaData>
<data>
<properties>
<property name="Filter1ChainingOperator" type="Microsoft.SharePoint.Publishing.WebControls.ContentByQueryWebPart+FilterChainingOperator, Microsoft.SharePoint.Publishing, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c">And</property>
<property name="FilterOperator1" type="Microsoft.SharePoint.Publishing.WebControls.ContentByQueryWebPart+FilterFieldQueryOperator, Microsoft.SharePoint.Publishing, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c">Eq</property>
<property name="Direction" type="direction">NotSet</property>
<property name="FilterOperator3" type="Microsoft.SharePoint.Publishing.WebControls.ContentByQueryWebPart+FilterFieldQueryOperator, Microsoft.SharePoint.Publishing, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c">Eq</property>
<property name="GroupByDirection" type="Microsoft.SharePoint.Publishing.WebControls.ContentByQueryWebPart+SortDirection, Microsoft.SharePoint.Publishing, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c">Desc</property>
<property name="DataSourceID" type="string" />
<property name="ChromeState" type="chromestate">Normal</property>
<property name="SystemViewFields" type="string" />
<property name="ListName" type="string" />
<property name="FilterDisplayValue3" type="string" />
<property name="FilterDisplayValue2" type="string" />
<property name="FilterDisplayValue1" type="string">In Progress</property>
<property name="FilterField1" type="string">{6e2d20e1-63ca-44c4-a57f-1f934d7f92ab}</property>
<property name="Description" type="string">Displays a dynamic view of content from your site.</property>
<property name="DataColumnRenames" type="string" />
<property name="MissingAssembly" type="string">Cannot import this Web Part.</property>
<property name="PageSize" type="int">-1</property>
<property name="ViewContentTypeId" type="string" />
<property name="ParameterBindings" type="string" />
<property name="HelpUrl" type="string" />
<property name="AdditionalFilterFields" type="string" />
<property name="DataMappingViewFields" type="string">{94f89715-e097-4e8b-ba79-ea02aa8b7adb},Lookup;{b9e6f3ae-5632-4b13-b636-9d1a2bd67120},Computed;{543bc2cf-1f30-488e-8f25-6fe3b689d9ac},Image;{fa564e0f-0c70-4ab9-b863-0177e6ddd247},Text;{691b9a4b-512e-4341-b3f1-68914130d5b2},Text;{1df5e554-ec7e-46a6-901d-d85a3881cb18},User;</property>
<property name="Title" type="string">In Progress</property>
<property name="FeedDescription" type="string" />
<property name="UseCache" type="bool">True</property>
<property name="XslLink" type="string" null="true" />
<property name="AutoRefresh" type="bool">False</property>
<property name="Filter1IsCustomValue" type="bool">False</property>
<property name="FireInitialRow" type="bool">True</property>
<property name="FilterValue3" type="string" />
<property name="SortByFieldType" type="string">DateTime</property>
<property name="ManualRefresh" type="bool">False</property>
<property name="HelpMode" type="helpmode">Modeless</property>
<property name="AllowConnect" type="bool">True</property>
<property name="ItemStyle" type="string">WithDocIcon</property>
<property name="SampleData" type="string"><dsQueryResponse>
<Rows>
<Row Title="Item 1" LinkUrl="http://Item1" Group="Group Header" __begincolumn="True" __begingroup="True" />
<Row Title="Item 2" LinkUrl="http://Item2" __begincolumn="False" __begingroup="False" />
<Row Title="Item 3" LinkUrl="http://Item3" __begincolumn="False" __begingroup="False" />
</Rows>
</dsQueryResponse></property>
<property name="FilterIncludeChildren2" type="bool">False</property>
<property name="XmlDefinitionLink" type="string" />
<property name="ServerTemplate" type="string">101</property>
<property name="TitleUrl" type="string" />
<property name="CommonViewFields" type="string">Modified,DateTime,;Modified By,User;Checked Out To, User;Check In Comment, Lookup;Author,User</property>
<property name="QueryOverride" type="string" />
<property name="DataSourcesString" type="string" />
<property name="DisplayName" type="string" />
<property name="ListGuid" type="string" />
<property name="DataFields" type="string" />
<property name="ShowWithSampleData" type="bool">False</property>
<property name="GroupByFieldType" type="string" />
<property name="Default" type="string" />
<property name="ViewFlags" type="Microsoft.SharePoint.SPViewFlags, Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c">None</property>
<property name="ContentTypeBeginsWithId" type="string" />
<property name="AllowHide" type="bool">True</property>
<property name="FeedEnabled" type="bool">False</property>
<property name="SortBy" type="string">{8c06beca-0777-48f7-91c7-6da68bc07b69}</property>
<property name="FilterByContextTerm" type="bool">False</property>
<property name="TitleIconImageUrl" type="string" />
<property name="PlayMediaInBrowser" type="bool">True</property>
<property name="ViewFlag" type="string">0</property>
<property name="Xsl" type="string"><xsl:stylesheet xmlns:x="http://www.w3.org/2001/XMLSchema" version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:cmswrt="http://schemas.microsoft.com/WebPart/v3/Publishing/runtime" exclude-result-prefixes="xsl cmswrt x" > <xsl:import href="/Style Library/XSL Style Sheets/Header.xsl" /> <xsl:import href="/Style Library/XSL Style Sheets/ItemStyle.xsl" /> <xsl:import href="/Style Library/XSL Style Sheets/ContentQueryMain.xsl" /> </xsl:stylesheet></property>
<property name="FilterField2" type="string" />
<property name="ChromeType" type="chrometype">TitleOnly</property>
<property name="CacheXslTimeOut" type="int">86400</property>
<property name="AdditionalGroupAndSortFields" type="string" />
<property name="UseSQLDataSourcePaging" type="bool">True</property>
<property name="Height" type="string" />
<property name="DataMappings" type="string">Author:|Modified:|Description:{691b9a4b-512e-4341-b3f1-68914130d5b2},ShortComment,Text;{1df5e554-ec7e-46a6-901d-d85a3881cb18},Author,User;|Title:{fa564e0f-0c70-4ab9-b863-0177e6ddd247},Title,Text;|CheckoutUser:|LinkUrl:{94f89715-e097-4e8b-ba79-ea02aa8b7adb},FileRef,Lookup;|ImageUrl:{b9e6f3ae-5632-4b13-b636-9d1a2bd67120},EncodedAbsThumbnailUrl,Computed;{543bc2cf-1f30-488e-8f25-6fe3b689d9ac},PublishingRollupImage,Image;|</property>
<property name="ListUrl" type="string" null="true" />
<property name="ShowUntargetedItems" type="bool">False</property>
<property name="AllowMinimize" type="bool">True</property>
<property name="GroupBy" type="string" />
<property name="FilterIncludeChildren1" type="bool">False</property>
<property name="BaseType" type="string" />
<property name="MainXslLink" type="string" />
<property name="AsyncRefresh" type="bool">False</property>
<property name="FilterValue1" type="string">In Progress</property>
<property name="FilterValue2" type="string" />
<property name="InitialAsyncDataFetch" type="bool">False</property>
<property name="AutoRefreshInterval" type="int">60</property>
<property name="Filter3IsCustomValue" type="bool">False</property>
<property name="GroupStyle" type="string">DefaultHeader</property>
<property name="AllowZoneChange" type="bool">True</property>
<property name="FilterIncludeChildren3" type="bool">False</property>
<property name="EnableOriginalValue" type="bool">False</property>
<property name="ItemLimit" type="int">15</property>
<property name="FilterType1" type="string">Choice</property>
<property name="UseCopyUtil" type="bool">False</property>
<property name="FilterType3" type="string" />
<property name="FilterType2" type="string" />
<property name="FilterOperator2" type="Microsoft.SharePoint.Publishing.WebControls.ContentByQueryWebPart+FilterFieldQueryOperator, Microsoft.SharePoint.Publishing, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c">Eq</property>
<property name="PageType" type="Microsoft.SharePoint.PAGETYPE, Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c">PAGE_NORMALVIEW</property>
<property name="FilterByAudience" type="bool">False</property>
<property name="ItemXslLink" type="string" />
<property name="Hidden" type="bool">False</property>
<property name="WebUrl" type="string">~sitecollection/dmwdocs</property>
<property name="HeaderXslLink" type="string" />
<property name="CacheXslStorage" type="bool">True</property>
<property name="ListsOverride" type="string" />
<property name="SortByDirection" type="Microsoft.SharePoint.Publishing.WebControls.ContentByQueryWebPart+SortDirection, Microsoft.SharePoint.Publishing, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c">Desc</property>
<property name="Filter2IsCustomValue" type="bool">False</property>
<property name="AllowEdit" type="bool">True</property>
<property name="FeedTitle" type="string" />
<property name="FilterField3" type="string" />
<property name="MediaPlayerStyleSource" type="string" null="true" />
<property name="DisplayColumns" type="int">1</property>
<property name="Filter2ChainingOperator" type="Microsoft.SharePoint.Publishing.WebControls.ContentByQueryWebPart+FilterChainingOperator, Microsoft.SharePoint.Publishing, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c">Or</property>
<property name="XmlDefinition" type="string" />
<property name="WebsOverride" type="string" />
<property name="AllowClose" type="bool">True</property>
<property name="ContentTypeName" type="string" />
<property name="ListId" type="System.Guid, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">00000000-0000-0000-0000-000000000000</property>
<property name="ExportMode" type="exportmode">All</property>
<property name="NoDefaultStyle" type="string" />
<property name="ViewFieldsOverride" type="string" />
<property name="CatalogIconImageUrl" type="string" />
<property name="ListDisplayName" type="string" null="true" />
<property name="Width" type="string" />
</properties>
</data>
Try editing web part property as shown in screen shot.CQWP
Here I have mentioned the column names explicitly in 'Fields to display' section. Please use display names.
In my case it was not showing Author(Created by) column .

Spring Integration - Oracle lock contention

The jdbc inbound channel adapter and message stores in our application consistenly stops querying for data and I've been able to track it down to a blocked Oracle session. In Oracle, we are getting enq: TX - row lock contention. The DBA tracked it down to the following:
SELECT COMPLETE, LAST_RELEASED_SEQUENCE, CREATED_DATE, UPDATED_DATE
from INT_MESSAGE_GROUP
where GROUP_KEY = :1 and REGION=:2
Any suggestions on how to resolve this would be greatly appreciated.
SI configuration (extract):
<int-jdbc:message-store id="jdbc-messageStore" data-source="dataSource" />
<int-jdbc:inbound-channel-adapter id="JDBCInboundChannel" query="${cache.integration.jdbc.selectQuery}"
channel="inboundMessagesChannel" data-source="dataSource" update="update CACHE_REPOSITORY set STATUS='P' WHERE GUID IN (:guid)" row-mapper="rowMapper"
max-rows-per-poll="${cache.integration.jdbc.maxRowsPerPoll}" auto-startup="false" >
<int:poller id="jdbcPoller" fixed-delay="${cache.integration.jdbc.fixedDelay}" >
<int:transactional />
</int:poller>
</int-jdbc:inbound-channel-adapter>
<int:chain...>
<int:aggregator id="reportTypeAggregator" ref="aggregatorBean" method="collect"
message-store="jdbc-messageStore" release-strategy="releaseStrategry"
release-strategy-method="canRelease" correlation-strategy="reportTypeCorrelationStrategry"
correlation-strategy-method="correlate" send-partial-result-on-expiry="true"
expire-groups-upon-completion="true" empty-group-min-timeout="30000" />
</int:chain>
<bean id="queryProvider" class="org.springframework.integration.jdbc.store.channel.OracleChannelMessageStoreQueryProvider"/>
<bean id="jdbc-channel-messageStore" class="org.springframework.integration.jdbc.store.JdbcChannelMessageStore">
<property name="dataSource" ref="dataSource"/>
<property name="channelMessageStoreQueryProvider" ref="queryProvider"/>
<property name="region" value="${cache.integration.channelMessageStore.region}"/>
</bean>
<int:channel id="archiveCreationChannel" >
<int:queue message-store="jdbc-channel-messageStore" />
<int:interceptors>
<int:wire-tap channel="logger" timeout="-1"/>
</int:interceptors>
</int:channel>
<bean id="documentMessageStoreReaper" class="org.springframework.integration.store.MessageGroupStoreReaper">
<property name="messageGroupStore" ref="jdbc-messageStore" />
<property name="timeout" value="${cache.integration.reaper.timeout}" />
<property name="autoStartup" value="false" />
</bean>
<task:scheduled-tasks>
<task:scheduled ref="documentMessageStoreReaper" method="run" fixed-rate="10000" />
</task:scheduled-tasks>
I suppose the main issue is around fixed-rate for documentMessageStoreReaper, which initiate the DELETE from INT_MESSAGE_GROUP. You should change it to the fixed-dealy to avoid concurrent tasks.
Since you say that the DELETE from INT_MESSAGE_GROUP is very long, hence 10 sec between tasks might be not enough.

Which threadsafe JobRepository for multithreaded Step?

While running spring batch job with partition, each of the slave threads are failing with the below error :
[SimpleAsyncTaskExecutor-2] AbstractStep.execute(250) | Encountered an error saving batch meta data. This job is now in an unknown state and should not be restarted.
org.springframework.dao.OptimisticLockingFailureException: Attempt to update step execution id=4623 with wrong version (1), where current version is 2 at org.springframework.batch.core.repository.dao.JdbcStepExecutionDao.updateStepExecution(JdbcStepExecutionDao.java:185) at org.springframework.batch.core.repository.support.SimpleJobRepository.update(SimpleJobRepository.java:171)
Job Repository being used is JobRepositoryFactoryBean. Spring batch version is 2.1.8 .
In BATCH_STEP_EXECUTION table, for all steps the version is 2, even while running the steps for the first time.
Job Configuration as below:
<job id="partitionJob" xmlns="http://www.springframework.org/schema/batch" parent="simpleJob">
<step id="masterStep" xmlns="http://www.springframework.org/schema/batch" parent="skipLimitStep">
<partition step="slave" partitioner="BulkPartitioner" xmlns="http://www.springframework.org/schema/batch">
<handler grid-size="10" task-executor="asyncTaskExecutor" xmlns="http://www.springframework.org/schema/batch" />
</partition>
</step>
</job>
<step id="slave" xmlns="http://www.springframework.org/schema/batch" parent="skipLimitStep">
<tasklet>
<chunk reader="partitionPagingItemReader" writer="partitionItemWriter" commit-interval="1" processor="partitionitemProcessor" skip-limit="1000">
</chunk>
<transaction-attributes propagation="REQUIRES_NEW" />
</tasklet>
</step>
<bean id="BulkPartitioner" class="foo.bar.BulkPartitioner" scope="step" >
<property name="model" value="#{jobParameters['abc']}"/>
</bean>
<bean id="partitionPagingItemReader" class="org.springframework.batch.item.database.JdbcPagingItemReader" scope="step" >
<property name="dataSource" ref="dataSource" />
<!-- <property name="fetchSize" value="#{jobParameters['fetch.size']}"></property> -->
<property name="fetchSize" value="1000"></property>
<property name="queryProvider">
<bean class="org.springframework.batch.item.database.support.SqlPagingQueryProviderFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="selectClause" value="select a, b, c" />
<property name="fromClause" value="from d" />
<property name="whereClause" value="where e= :f" />
<property name="sortKey" value="e" />
</bean>
</property>
<!-- Inject via the ExecutionContext in rangePartitioner -->
<property name="parameterValues">
<map>
<entry key="f" value="#{stepExecutionContext[f]}" />
</map>
</property>
<property name="pageSize" value="1" />
<property name="rowMapper">
<bean class="foo.bar.mapper" />
</property>
</bean>
<bean id="simpleJob"
class="org.springframework.batch.core.job.SimpleJob" abstract="true">
<property name="jobRepository" ref="jobRepository"/>
<property name="restartable" value="true"/>
</bean>
<bean id="jobRepository"
class="org.springframework.batch.core.repository.support.JobRepositoryFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="databaseType" value="oracle"/>
<property name="transactionManager" ref="transactionManager"/>
<property name="isolationLevelForCreate" value="ISOLATION_DEFAULT"/>
<property name="validateTransactionState" value="false"/>
</bean>
update: This is happening only for failed steps. successful completion of steps are updated correctly.
What could be the cause? TIA.
In case this is a problem for others, this was the solution I found:
<property name="saveState" value="false" />
in the reader(s)/writer(s) for the concurrent job/step. As the logging mentions, "This job is now in an unknown state and should not be restarted" so you should consider:
<property name="restartable" value="false"/>
Sources:
http://docs.spring.io/spring-batch/reference/html/scalability.html
http://docs.spring.io/spring-batch/reference/html/readersAndWriters.html#process-indicator

Spring Integration Exception ignoring container setting on int-jms:message-driven-channel-adapter

As per my understanding, Runtime Exception in ServiceActivator should send message to errorChannel.
But if errorHandler is not set then that doesn't work. I even tried to set errorHandler
<bean id="translatorContainer" class="org.springframework.jms.listener.DefaultMessageListenerContainer">
<property name="connectionFactory" ref="connectionFactory" />
<property name="errorHandler" ref="myErrorHandler"/>
<property name="destination" ref="TRANSLATED-MDCAD" />
<property name="sessionTransacted" value="true" />
<property name="maxConcurrentConsumers" value="50" />
<property name="concurrentConsumers" value="1" />
<property name="receiveTimeout" value="5000" />
<property name="recoveryInterval" value="60000" />
<property name="autoStartup" value="false" />
</bean>
<int:channel id="TRANSLATED-MSG-CHANNEL"/>
<bean id="TRANSLATED-MDCAD" class="com.ibm.mq.jms.MQQueue">
<constructor-arg value="TRANSLATED-MESSAGE-QUEUE" />
</bean>
<int-jms:message-driven-channel-adapter
id="MDB-TRANSLATED"
channel="TRANSLATED-MSG-CHANNEL" container="translatorContainer" acknowledge="transacted"/>
<int:service-activator input-channel="IN-MSG-CHANNEL"
output-channel="TRANSLATED-MSG-CHANNEL" ref="myProcess"
method="execute" />
But on RuntimeException in myProcess (ServiceActivator) then i am seeing following in log
WARN : [2014-03-16 00:11:51.219] org.springframework.jms.listener.DefaultMessageListenerContainer - Execution of JMS message listener failed, and no ErrorHandler has been set.
org.springframework.integration.MessagingException: failed to handle incoming JMS Message
at org.springframework.integration.jms.SubscribableJmsChannel$DispatchingMessageListener.onMessage(SubscribableJmsChannel.java:164)
at org.springframework.jms.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:561)
at org.springframework.jms.listener.AbstractMessageListenerContainer.invokeListener(AbstractMessageListenerContainer.java:499)
at org.springframework.jms.listener.AbstractMessageListenerContainer.doExecuteListener(AbstractMessageListenerContainer.java:467)
at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:325)
at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:263)
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:1059)
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.executeOngoingLoop(DefaultMessageListenerContainer.java:1051)
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:948)
at java.lang.Thread.run(Thread.java:662)
I have debugged DefaultMessageListenerContainer, JmsMessageDrivenEndpointParser and some other internal class and found that container is getting set correctly.
BUT when exception is thrown, it is using default container ( not the one i have set on int-jms:message-driven-channel-adapter : translatorContainer which has errorHandler set )
What could be the reason? Is there any other alternate setup I can try to redirect runtime exception to errorChannel? Let me know if you need more information
I am using spring integration version 2.2.5
#### DETAIL CONFIG
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:int="http://www.springframework.org/schema/integration"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:int-jms="http://www.springframework.org/schema/integration/jms"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/integration/jms http://www.springframework.org/schema/integration/jms/spring-integration-jms.xsd
">
<bean id="connectionFactory" class="com.ibm.mq.jms.MQQueueConnectionFactory">
<property name="hostName">
<value>${mq_hostname}</value>
</property>
<property name="port">
<value>${mq_port}</value>
</property>
<property name="queueManager">
<value>${mq_queuemanager}</value>
</property>
<property name="channel">
<value>${mq_channel}</value>
</property>
<property name="transportType" value="1" />
<property name="useConnectionPooling">
<value>true</value>
</property>
</bean>
<int:annotation-config />
<int:message-history />
<bean id="defaultMessageListenerContainer" class="org.springframework.jms.listener.DefaultMessageListenerContainer">
<property name="destination" ref="DEBATCHED-MDCAD" />
<property name="connectionFactory" ref="connectionFactory" />
<property name="errorHandler" ref="manifestErrorHandler"/>
<property name="sessionTransacted" value="true" />
<property name="maxConcurrentConsumers" value="50" />
<property name="concurrentConsumers" value="1" />
<property name="receiveTimeout" value="5000" />
<property name="recoveryInterval" value="60000" />
<property name="autoStartup" value="false" />
</bean>
</bean>
<bean id="translatorContainer" class="org.springframework.jms.listener.DefaultMessageListenerContainer">
<property name="destination" ref="TRANSLATED-MDCAD" />
<property name="connectionFactory" ref="connectionFactory" />
<property name="errorHandler" ref="manifestErrorHandler"/>
<property name="sessionTransacted" value="true" />
<property name="maxConcurrentConsumers" value="50" />
<property name="concurrentConsumers" value="1" />
<property name="receiveTimeout" value="5000" />
<property name="recoveryInterval" value="60000" />
<property name="autoStartup" value="false" />
</bean>
</bean>
<!-- Global Channel Interceptor -->
<int:channel-interceptor ref="metadataInterceptor"
pattern="*CHANNEL" order="1" />
<int:wire-tap pattern="*CHANNEL" order="1" channel="logger" />
<int:gateway id="manifestGateway"
service-interface="gov.dhs.cbp.manifest.oceanexport.gateway.ManifestGateway" error-channel="ERRORS-MSG-CHANNEL" />
<int:logging-channel-adapter id="logger"
level="ERROR" log-full-message="true" />
<int-jms:channel id="INBOUND-MSG-CHANNEL" queue-name="INBOUND" error-handler="manifestErrorHandler"/>
<int:channel id="DEBATCHED-MSG-CHANNEL" />
<bean id="DEBATCHED-MDCAD" class="com.ibm.mq.jms.MQQueue">
<constructor-arg value="DEBATCHED" />
</bean>
<int-jms:message-driven-channel-adapter
id="MDB-DEBATCHED"
channel="DEBATCHED-MSG-CHANNEL" container="defaultMessageListenerContainer" acknowledge="transacted"/>
<bean id="manifestErrorHandler" class="gov.dhs.cbp.manifest.process.util.ManifestErrorHandler"/>
<int:channel id="TRANSLATED-MSG-CHANNEL"/>
<bean id="TRANSLATED-MDCAD" class="com.ibm.mq.jms.MQQueue">
<constructor-arg value="TRANSLATED" />
</bean>
<int-jms:message-driven-channel-adapter
id="MDB-TRANSLATED"
channel="TRANSLATED-MSG-CHANNEL" container="translatorContainer" acknowledge="transacted"/>
<int:channel id="ERRORS-MSG-CHANNEL" />
<bean id="ERROR-EXTERNAL" class="com.ibm.mq.jms.MQQueue">
<constructor-arg value="ERRORS" />
</bean>
<int-jms:outbound-channel-adapter id="ERROR-EXTERNAL-ADAPTER"
channel="ERRORS-MSG-CHANNEL" destination="ERROR-EXTERNAL" />
<int-jms:outbound-channel-adapter id="ERROR-CHANNEL-EXTERNAL-ADAPTER"
channel="errorChannel" destination="ERROR-EXTERNAL" />
<!-- ## Service Activator ## -->
<int:service-activator input-channel="DEBATCHED-MSG-CHANNEL"
output-channel="TRANSLATED-MSG-CHANNEL" ref="manifestProcess"
method="execute" />
<!-- DEBATCHER - SPLITTER -->
<int:splitter input-channel="INBOUND-MSG-CHANNEL"
output-channel="DEBATCHED-MSG-CHANNEL" ref="debatcherService"
method="execute" />
<!-- RESPONSE SERVICE / NOT ROUTER DUE TO BUSINESS LOGIC -->
<int:service-activator input-channel="TRANSLATED-MSG-CHANNEL" ref="responseService"
method="generateResponse"/>
<bean id="pool"
class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor">
<property name="corePoolSize" value="8" />
</bean>
<!--
<bean id="retryTemplate" class="org.springframework.retry.support.RetryTemplate">
<property name="retryPolicy">
<bean class="org.springframework.retry.policy.SimpleRetryPolicy">
<property name="maxAttempts" value="4" />
</bean>
</property>
<property name="backOffPolicy">
<bean class="org.springframework.retry.backoff.ExponentialBackOffPolicy">
<property name="initialInterval" <value="1000" />
<property name="multiplier" value="5" />
</bean>
</property>
</bean>
-->
</beans>
USING RETRY template to solve the issue
<bean id="retryTemplate" class="org.springframework.retry.support.RetryTemplate">
<property name="retryPolicy">
<bean class="org.springframework.retry.policy.SimpleRetryPolicy">
<property name="maxAttempts" value="1" />
</bean>
</property>
<property name="backOffPolicy">
<bean class="org.springframework.retry.backoff.ExponentialBackOffPolicy">
<property name="initialInterval" value="1000" />
<property name="multiplier" value="5" />
</bean>
</property>
</bean>
<int:service-activator input-channel="DEBATCHED-MSG-CHANNEL"
output-channel="TRANSLATED-MSG-CHANNEL" ref="manifestProcess"
method="execute" >
<int:request-handler-advice-chain>
<bean class="org.springframework.integration.handler.advice.RequestHandlerRetryAdvice">
<property name="recoveryCallback">
<bean class="org.springframework.integration.handler.advice.ErrorMessageSendingRecoverer">
<constructor-arg ref="errorChannel" />
</bean>
</property>
<property name="retryTemplate" ref="retryTemplate" />
</bean>
</int:request-handler-advice-chain>
</int:service-activator>
As we see by your StackTrace the issue is around SubscribableJmsChannel (<int-jms:channel id="fooChannel" queue-name="foo"/>), where you don't use a custom container.
But you show a config for <int-jms:message-driven-channel-adapter>.
So, be careful analyzing the issue.
Now, if you want the same behaviour for <int-jms:channel/> you can inject your myErrorHandler to the channel's property error-handler

Resources