-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added entity to store message idempotent store, basically to check if…
… given messageId is already processed or not, if yes then are there any errors. Also fixed minor issues in TransactionReaderCallback w.r.to rawdata sequence key
- Loading branch information
Showing
6 changed files
with
239 additions
and
23 deletions.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
appdefn/src/main/resources/db/migration/hsqldb/V0_1_0_0_7__Added_MessageIdempotentStore.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
|
||
CREATE TABLE "statements"."MessageIdempotentStore"("id" BIGINT GENERATED BY DEFAULT AS IDENTITY(START WITH 0) NOT NULL,"error" VARCHAR(2000),"messageId" VARCHAR(1000) NOT NULL,CONSTRAINT "MessageIdempotentStore_PK" PRIMARY KEY("id"),CONSTRAINT "MessageIdempotentStore_messageId_UNQ" UNIQUE("messageId")); | ||
ALTER TABLE "statements"."MessageIdempotentStore" ALTER COLUMN "id" RESTART WITH 0; | ||
|
||
CREATE INDEX "MessageIdempotentStore_N52" ON "statements"."MessageIdempotentStore"("messageId"); |
100 changes: 100 additions & 0 deletions
100
module-rdr/src/main/java/domainapp/modules/rdr/dom/MessageIdempotentStore.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
package domainapp.modules.rdr.dom; | ||
|
||
import javax.jdo.annotations.IdentityType; | ||
import javax.jdo.annotations.VersionStrategy; | ||
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; | ||
|
||
import org.apache.isis.applib.annotation.Auditing; | ||
import org.apache.isis.applib.annotation.CommandReification; | ||
import org.apache.isis.applib.annotation.DomainObject; | ||
import org.apache.isis.applib.annotation.Editing; | ||
import org.apache.isis.applib.annotation.MemberOrder; | ||
import org.apache.isis.applib.annotation.Property; | ||
import org.apache.isis.applib.annotation.PropertyLayout; | ||
import org.apache.isis.applib.annotation.Publishing; | ||
import org.apache.isis.applib.annotation.Title; | ||
import org.apache.isis.applib.annotation.Where; | ||
import org.apache.isis.schema.utils.jaxbadapters.PersistentEntityAdapter; | ||
|
||
import domainapp.modules.base.entity.NamedQueryConstants; | ||
import domainapp.modules.base.entity.WithDescription; | ||
import domainapp.modules.base.entity.WithName; | ||
import domainapp.modules.ref.StaticModule.ActionDomainEvent; | ||
import lombok.Builder; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.Getter; | ||
import lombok.Setter; | ||
import lombok.ToString; | ||
|
||
@javax.jdo.annotations.PersistenceCapable( | ||
identityType=IdentityType.DATASTORE, | ||
schema = "statements" | ||
) | ||
@javax.jdo.annotations.DatastoreIdentity( | ||
strategy=javax.jdo.annotations.IdGeneratorStrategy.IDENTITY, | ||
column="id") | ||
@javax.jdo.annotations.Queries({ | ||
@javax.jdo.annotations.Query( | ||
name = NamedQueryConstants.QUERY_ALL, | ||
value = "SELECT " | ||
+ "FROM domainapp.modules.rdr.dom.MessageIdempotentStore "), | ||
@javax.jdo.annotations.Query( | ||
name = MessageIdempotentStore.QUERY_FIND_BY_MESSAGE_ID, | ||
value = "SELECT " | ||
+ "FROM domainapp.modules.rdr.dom.MessageIdempotentStore " | ||
+ "WHERE messageId.indexOf(:messageId) >= 0 ") | ||
}) | ||
@javax.jdo.annotations.Unique(name="MessageIdempotentStore_messageId_UNQ", members = {"messageId"}) | ||
@DomainObject( | ||
auditing = Auditing.ENABLED, | ||
publishing = Publishing.ENABLED, | ||
objectType = "reader.MessageIdempotentStore", | ||
bounded = true | ||
) // objectType inferred from @PersistenceCapable#schema | ||
@XmlJavaTypeAdapter(PersistentEntityAdapter.class) | ||
@EqualsAndHashCode(of = {"messageId"}) | ||
@ToString(of = {"messageId"}) | ||
public class MessageIdempotentStore implements Comparable<MessageIdempotentStore> { | ||
|
||
public static final String QUERY_FIND_BY_MESSAGE_ID = "findByMessageId"; //$NON-NLS-1$ | ||
|
||
@javax.jdo.annotations.Column(allowsNull = "false", length = 1000) | ||
@Property(editing = Editing.DISABLED) | ||
@Getter @Setter | ||
private String messageId; | ||
|
||
@javax.jdo.annotations.Column(length = 2000) | ||
@Property(editing = Editing.DISABLED) | ||
@Getter @Setter | ||
private String error; | ||
|
||
@Builder | ||
public MessageIdempotentStore(final String messageId, final String error) { | ||
setMessageId(messageId); | ||
setError(error); | ||
} | ||
|
||
public MessageIdempotentStore(MessageIdempotentStore messageIdempotentStore) { | ||
this( | ||
messageIdempotentStore.getMessageId(), | ||
messageIdempotentStore.getError() | ||
); | ||
} | ||
|
||
public static class CreateEvent extends ActionDomainEvent<MessageIdempotentStore> { | ||
private static final long serialVersionUID = 1L; | ||
} | ||
|
||
public static class UpdateEvent extends ActionDomainEvent<MessageIdempotentStore> { | ||
private static final long serialVersionUID = 1L; | ||
} | ||
|
||
@Override | ||
public int compareTo(final MessageIdempotentStore other) { | ||
if (other == null) { | ||
return -1; | ||
} | ||
return getMessageId().compareTo(other.getMessageId()); | ||
} | ||
|
||
} |
66 changes: 66 additions & 0 deletions
66
module-rdr/src/main/java/domainapp/modules/rdr/service/MessageIdempotentStoreService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/** | ||
* | ||
*/ | ||
package domainapp.modules.rdr.service; | ||
|
||
import java.util.List; | ||
|
||
import org.apache.isis.applib.annotation.DomainService; | ||
import org.apache.isis.applib.annotation.NatureOfService; | ||
import org.apache.isis.applib.annotation.Programmatic; | ||
|
||
import domainapp.modules.base.entity.NamedQueryConstants; | ||
import domainapp.modules.base.service.AbstractService; | ||
import domainapp.modules.rdr.dom.MessageIdempotentStore; | ||
|
||
/** | ||
* Idempotent store for message ids<br> | ||
* Optionally error can also be stored indicating any processing error for given message id. | ||
* | ||
* @author jayeshecs | ||
*/ | ||
@DomainService( | ||
nature = NatureOfService.DOMAIN, | ||
repositoryFor = MessageIdempotentStore.class | ||
) | ||
public class MessageIdempotentStoreService extends AbstractService<MessageIdempotentStore> { | ||
|
||
public MessageIdempotentStoreService() { | ||
super(MessageIdempotentStore.class); | ||
} | ||
|
||
@Programmatic | ||
public List<MessageIdempotentStore> all() { | ||
return search(NamedQueryConstants.QUERY_ALL); | ||
} | ||
|
||
@Programmatic | ||
public MessageIdempotentStore create(String messageId, String error) { | ||
MessageIdempotentStore newMessageIdempotentStore = MessageIdempotentStore.builder().messageId(messageId).error(error).build(); | ||
MessageIdempotentStore MessageIdempotentStore = repositoryService.persistAndFlush(newMessageIdempotentStore); | ||
return MessageIdempotentStore; | ||
} | ||
|
||
@Programmatic | ||
public MessageIdempotentStore find(String messageId) { | ||
List<MessageIdempotentStore> list = search(MessageIdempotentStore.QUERY_FIND_BY_MESSAGE_ID, "messageId", messageId); | ||
if (list == null || list.isEmpty()) { | ||
return null; // nothing found | ||
} | ||
for (MessageIdempotentStore store : list) { | ||
if (store.getMessageId().equals(messageId)) { | ||
return store; // found | ||
} | ||
} | ||
return null; // exact match not found | ||
} | ||
|
||
@Programmatic | ||
public void clear(String messageId) { | ||
List<MessageIdempotentStore> list = search(MessageIdempotentStore.QUERY_FIND_BY_MESSAGE_ID, "messageId", messageId); | ||
if (list == null || list.isEmpty()) { | ||
return ; // nothing found | ||
} | ||
delete(list); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,21 @@ | ||
#!/bin/sh | ||
echo copying standalong statements.war file... | ||
|
||
echo "Copying standalong statements.war file..." | ||
|
||
cp webapp/target/statements-webapp-*-jetty*.war ./statements.war | ||
echo Start statements application ... | ||
if [ "$1" == "headless" ] | ||
then | ||
nohup java -jar statements.war --headless 2>&1 > logs/console.log & | ||
else | ||
nohup java -jar statements.war 2>&1 > logs/console.log & | ||
|
||
echo "Start statements application ..." | ||
|
||
JETTY_CONSOLE_OPTIONS="--port 8080" | ||
|
||
if [ "$1" = "headless" ]; then | ||
JETTY_CONSOLE_OPTIONS="$JETTY_CONSOLE_OPTIONS --headless" | ||
fi | ||
echo To see progress make use of below command | ||
echo tail -f logs/console.log | ||
echo "Running command 'nohup java -jar statements.war $JETTY_CONSOLE_OPTIONS 2>&1 > logs/console.log &' ..." | ||
nohup java -jar statements.war $JETTY_CONSOLE_OPTIONS 2>&1 > logs/console.log & | ||
|
||
echo "To see progress make use of below command" | ||
echo "tail -f logs/console.log" | ||
|
||
|
||
|