use of com.adaptris.interlok.InterlokException in project interlok by adaptris.
the class InterlokJmxClientTest method testMessageTarget_NoWorkflow.
@Test
public void testMessageTarget_NoWorkflow() throws Exception {
MyMessageProcessor proc = new MyMessageProcessor();
DefaultSerializableMessage msg = new DefaultSerializableMessage().withPayload(testName.getMethodName());
register(createObjectName(new MessageTarget().withAdapter(testName.getMethodName()).withChannel(testName.getMethodName()).withWorkflow(testName.getMethodName())), proc);
MessageTarget notFound = new MessageTarget().withAdapter(testName.getMethodName()).withChannel(testName.getMethodName()).withWorkflow("abcde");
InterlokJmxClient client = new InterlokJmxClient(jmxConnectorServer.getAddress());
try {
client.connect();
client.processAsync(notFound, msg);
fail();
} catch (InterlokException expected) {
assertTrue(expected.getMessage().endsWith(" does not narrow to a single workflow"));
} finally {
client.disconnect();
}
}
use of com.adaptris.interlok.InterlokException in project interlok by adaptris.
the class InterlokJmxClientTest method testMessageTarget_Wildcard.
@Test
public void testMessageTarget_Wildcard() throws Exception {
MyMessageProcessor proc = new MyMessageProcessor();
MyMessageProcessor proc2 = new MyMessageProcessor();
MessageTarget target1 = new MessageTarget().withAdapter(testName.getMethodName()).withChannel(testName.getMethodName()).withWorkflow(testName.getMethodName());
MessageTarget target2 = new MessageTarget().withAdapter(testName.getMethodName()).withChannel(testName.getMethodName()).withWorkflow(testName.getMethodName() + "2");
DefaultSerializableMessage msg = new DefaultSerializableMessage().withPayload(testName.getMethodName());
register(createObjectName(target1), proc);
register(createObjectName(target2), proc2);
MessageTarget wildcard = new MessageTarget().withAdapter(testName.getMethodName()).withChannel(testName.getMethodName()).withWorkflow("*");
InterlokJmxClient client = new InterlokJmxClient(jmxConnectorServer.getAddress());
try {
client.connect();
client.processAsync(wildcard, msg);
fail();
} catch (InterlokException expected) {
assertTrue(expected.getMessage().endsWith(" does not narrow to a single workflow"));
} finally {
client.disconnect();
}
}
use of com.adaptris.interlok.InterlokException in project interlok by adaptris.
the class ExceptionAsStringReportTest method testDoService_Payload_Exception.
@Test
public void testDoService_Payload_Exception() throws Exception {
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage();
msg.addObjectHeader(CoreConstants.OBJ_METADATA_EXCEPTION, new Exception("This is the exception"));
ExceptionReportService service = new ExceptionReportService(new ExceptionAsString().withTarget(new DataOutputParameter<String>() {
@Override
public void insert(String data, InterlokMessage msg) throws InterlokException {
throw new CoreException();
}
}));
try {
execute(service, msg);
fail();
} catch (ServiceException expected) {
}
}
use of com.adaptris.interlok.InterlokException in project interlok by adaptris.
the class FilesystemRetryStore method getMetadata.
@Override
public Map<String, String> getMetadata(String msgId) throws InterlokException {
try {
File dir = validateMsgId(msgId, true);
File metaFile = FsWorker.isFile(FsWorker.checkReadable(new File(dir, METADATA_FILE_NAME)));
Properties meta = new Properties();
try (InputStream in = new FileInputStream(metaFile)) {
meta.load(in);
}
// The compiler works in mysterious ways.
return (Map) meta;
} catch (Exception e) {
throw ExceptionHelper.wrapInterlokException(e);
}
}
use of com.adaptris.interlok.InterlokException in project interlok by adaptris.
the class FilesystemRetryStore method write.
@Override
public void write(AdaptrisMessage msg) throws InterlokException {
try {
File dir = validateMsgId(msg.getUniqueId(), false);
log.trace("Created [{}]", dir.getCanonicalPath());
File payloadFile = new File(dir, PAYLOAD_FILE_NAME);
File metadataFile = new File(dir, METADATA_FILE_NAME);
File exceptionFile = new File(dir, STACKTRACE_FILENAME);
storePayload(msg, payloadFile);
storeMetadata(msg, metadataFile);
storeException(msg, exceptionFile);
} catch (Exception e) {
throw ExceptionHelper.wrapInterlokException(e);
}
}
Aggregations