本文整理汇总了Java中org.apache.camel.Handler类的典型用法代码示例。如果您正苦于以下问题:Java Handler类的具体用法?Java Handler怎么用?Java Handler使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Handler类属于org.apache.camel包,在下文中一共展示了Handler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import org.apache.camel.Handler; //导入依赖的package包/类
@Handler
public void execute(EventData eventData) {
try {
EventGenerator eg = EventGeneratorFactory.getEventGenerator(eventData.domainId,
eventData.objectType);
if(eventData.eventId == IEvent.DELETED) {
DomainConfig dc = DomainConfig.getInstance(eventData.domainId);
eg.generateDeleteEvent(eg, eventData.eventObject, eventData.objectId, dc.getLocale(), dc.getTimezone(), eventData.params);
} else {
eg.generate(eventData.eventId, eventData.params, eventData.objectId,
eventData.customOptions);
}
} catch (Exception e) {
log.severe("Issue with submitted task {0} with error {1}", eventData, e.getMessage(), e);
throw new RuntimeException(e);
}
}
示例2: enhanceMessage
import org.apache.camel.Handler; //导入依赖的package包/类
@Handler
public String enhanceMessage( String body, Exchange exchange ) {
String[] topicParts = exchange.getIn().getHeader("CamelMQTTSubscribeTopic", String.class).split(TOPIC_SEPARTOR);
if(topicParts.length != 4) {
throw new IllegalArgumentException("Invalid number of topic components. Expected " + TOPIC_PART_SIZE + ". Was " + topicParts.length);
}
StringBuilder sb = new StringBuilder();
sb.append(body);
sb.append(COMMA);
sb.append(topicParts[1]);
sb.append(COMMA);
sb.append(topicParts[2]);
sb.append(COMMA);
sb.append(topicParts[3]);
return sb.toString();
}
示例3: processCsv
import org.apache.camel.Handler; //导入依赖的package包/类
@Handler
public void processCsv(Exchange exchange) {
// We assume Camel CSV is used beforehand to set the body to a List<List<String>>
@SuppressWarnings("unchecked")
List<List<String>> list = (List<List<String>>) exchange.getIn().getBody();
List<String> tokens = list.get(0);
// Build up a model for Velocity to use
Map<String, Object> model = new HashMap<String, Object>();
String[] nameParts = tokens.get(0).split(" ");
model.put("firstName", nameParts[0]);
model.put("lastName", nameParts[1]);
model.put("birthDate", tokens.get(1));
exchange.getIn().setBody(model);
// Set the header required by ml-xcc for ingestion
exchange.getIn().setHeader("MlXccUri", tokens.get(0) + ".xml");
}
示例4: fetch
import org.apache.camel.Handler; //导入依赖的package包/类
@Handler
public FetchData fetch(ScrapeTemplate template,
Map<String, Object> actualParams) {
LowerEnumSerializer.LOWER = false;
final String uri = template.getUri();
log.info("Fetching {} {} {} ...", template.getProtocol(), template.getProtocolVersion(),
template.getUri());
try {
// FIXME: Use Retryer (with limit) when: Caused by: java.net.SocketException: Connection reset
// at java.net.SocketInputStream.read(SocketInputStream.java:209)
switch (template.getProtocol()) {
case JSONRPC:
return fetchJsonRpc(uri, template, actualParams);
case HTTP:
throw new UnsupportedOperationException("no HTTP support yet");
default:
throw new UnsupportedOperationException("Unsupported protocol: " + template.getProtocol());
}
} catch (Exception e) {
throw new ScrapeException(e, "Cannot fetch %s", uri);
}
}
示例5: getDsMetaData
import org.apache.camel.Handler; //导入依赖的package包/类
/**
* Return a {@link DsMetaData} response.
*
* @param inputString
* input message body
* @return meta data XML entity instance
*/
@Handler
@InOnly
public DsMetaData getDsMetaData(final String inputString)
{
if (log.isDebugEnabled())
{
log.debug(getDataSourcePrefix() + "getDsMetaData()");
// " inputString "
// + inputString);
}
// For test assertion simplicity, the name field below does not depend on
// the input string. Only the description field does.
return new DsMetaData(name, name + ": " + inputString);
}
示例6: lastFileProcessed
import org.apache.camel.Handler; //导入依赖的package包/类
@Handler
public boolean lastFileProcessed(Exchange exchange) throws Exception {
FileEntryWorkNote workNote = exchange.getIn().getBody(FileEntryWorkNote.class);
String batchJobId = workNote.getBatchJobId();
TenantContext.setJobId(batchJobId);
if (batchJobDAO.updateFileEntryLatch(workNote.getBatchJobId(), workNote.getFileEntry().getFileName())) {
RangedWorkNote wn = RangedWorkNote.createSimpleWorkNote(batchJobId);
exchange.getIn().setBody(wn, RangedWorkNote.class);
return true;
}
return false;
}
示例7: processCommand
import org.apache.camel.Handler; //导入依赖的package包/类
@Handler
public void processCommand(Exchange exch) throws Exception {
String command = exch.getIn().getBody().toString();
LOG.info("Received: " + command);
String[] chunks = command.split("\\|");
if (JOB_COMPLETED.equals(chunks[0])) {
LOG.info("Clearing cache at job completion.");
dumpAspectTrackers(chunks);
} else {
LOG.error("Unsupported command");
}
}
示例8: getRetweetsWithScreenNames
import org.apache.camel.Handler; //导入依赖的package包/类
@Handler
public List<String> getRetweetsWithScreenNames(@Header("statusId") Long statusId)
throws TwitterException {
return twitter.getRetweets(statusId).stream()
.map(tweet -> tweet.getUser().getScreenName())
.collect(Collectors.toList());
}
示例9: log
import org.apache.camel.Handler; //导入依赖的package包/类
@Handler
public void log(@Body Object body){
if(trace) {
LOGGER.trace("Body is: {}",body);
} else {
LOGGER.info("Body is: {}",body);
}
}
示例10: execute
import org.apache.camel.Handler; //导入依赖的package包/类
@Handler
public void execute(TaskOptions taskOptions) {
jmsMeter.mark();
log.info("Submitting task with parameter{0}", taskOptions);
//localQueue.add(taskOptions);
Task simpleTask = new SimpleTask(taskOptions);
try {
((Runnable) simpleTask).run();
} catch (Exception e) {
log.severe("Issue with submitted task {0} with error {1}", taskOptions, e.getMessage(), e);
throw e;
}
}
示例11: execute
import org.apache.camel.Handler; //导入依赖的package包/类
@Handler
public void execute(AssetStatusRequest assetStatusRequest) throws ServiceException {
jmsMeter.mark();
List<AssetStatusModel> assetStatusModelList = assetStatusRequest.data;
if (assetStatusModelList != null && !assetStatusModelList.isEmpty()) {
AssetManagementService assetManagementService = Services
.getService(AssetManagementServiceImpl.class);
assetManagementService
.updateAssetStatus(build(assetStatusModelList, assetManagementService));
}
}
示例12: process
import org.apache.camel.Handler; //导入依赖的package包/类
@Handler
public void process(@XPath("//title") String title,
@XPath("//description") String description,
@XPath("//pubDate") String pubDate,
@XPath("//link") String link) {
ZonedDateTime published = ZonedDateTime.parse(pubDate, DateTimeFormatter.RFC_1123_DATE_TIME);
if (ChronoUnit.MINUTES.between(published,
ZonedDateTime.now()) <= threshold) {
bus.broadcast(parser.parse(description, title, link))
.as("status.redhat");
}
}
示例13: throwNonBpmnException
import org.apache.camel.Handler; //导入依赖的package包/类
@Handler
public void throwNonBpmnException() throws Exception {
LOGGER.debug("throwing non bpmn bug");
switch (getExceptionType()) {
case NO_EXCEPTION:
break;
case NON_BPMN_EXCEPTION:
throw new Exception("arbitrary non bpmn exception");
case BPMN_EXCEPTION:
throw new BpmnError("testError");
}
}
示例14: handler
import org.apache.camel.Handler; //导入依赖的package包/类
@Handler
public void handler(@XPath("//response/text()") String response,
@XPath(headerName = "invoiceDetails", value = "//invoice/person/name/text()") String userName,
@XPath(headerName = "invoiceDetails", value = "//invoice/person/date", resultType = String.class) String date) {
this.response = response;
this.userName = userName;
this.date = date;
}
示例15: consume
import org.apache.camel.Handler; //导入依赖的package包/类
@Handler
public String consume() {
StringBuilder result = new StringBuilder();
Exchange exchange;
while ((exchange = consumer.receive("activemq:queue", 2000)) != null) {
result.append(exchange.getIn().getBody(String.class));
}
return result.toString();
}