本文整理了Java中org.apache.camel.Message.setHeader()
方法的一些代码示例,展示了Message.setHeader()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Message.setHeader()
方法的具体详情如下:
包路径:org.apache.camel.Message
类名称:Message
方法名:setHeader
暂无
代码示例来源:origin: deeplearning4j/nd4j
@Override
public void process(Exchange exchange) throws Exception {
final INDArray arr = (INDArray) exchange.getIn().getBody();
ByteArrayOutputStream bos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(bos);
Nd4j.write(arr, dos);
byte[] bytes = bos.toByteArray();
String base64 = Base64.encodeBase64String(bytes);
exchange.getIn().setBody(base64, String.class);
String id = UUID.randomUUID().toString();
exchange.getIn().setHeader(KafkaConstants.KEY, id);
exchange.getIn().setHeader(KafkaConstants.PARTITION_KEY, id);
}
}).to(kafkaUri);
代码示例来源:origin: org.apache.camel/camel-caffeine
private void setResult(Message message, boolean success, Object result, Object oldValue) {
message.setHeader(CaffeineConstants.ACTION_SUCCEEDED, success);
message.setHeader(CaffeineConstants.ACTION_HAS_RESULT, oldValue != null || result != null);
if (oldValue != null) {
message.setHeader(CaffeineConstants.OLD_VALUE, oldValue);
}
if (result != null) {
message.setBody(result);
}
}
}
代码示例来源:origin: io.syndesis.connector/connector-google-calendar
private void beforeProducer(Exchange exchange) throws MessagingException, IOException, ParseException {
final Message in = exchange.getIn();
in.setHeader("CamelGoogleCalendar.eventId", eventId);
in.setHeader("CamelGoogleCalendar.calendarId", calendarId);
}
代码示例来源:origin: org.apache.camel/camel-test
/**
* A strategy method to populate an exchange with some example values for use
* by language plugins
*/
protected void populateExchange(Exchange exchange) {
Message in = exchange.getIn();
in.setHeader("foo", "abc");
in.setHeader("bar", 123);
in.setBody("<hello id='m123'>world!</hello>");
}
代码示例来源:origin: org.openehealth.ipf.platform-camel/ipf-platform-camel-flow
/**
* Writes the flow id to the contained {@link Exchange}.
*
* @param flowId
* flow identifier.
*/
@Override
public void setFlowId(Long flowId) {
exchange.getIn().setHeader(FLOW_ID_KEY, flowId);
}
代码示例来源:origin: org.apache.camel/camel-caffeine
private void setResult(Message message, boolean success, Object result, Object oldValue) {
message.setHeader(CaffeineConstants.ACTION_SUCCEEDED, success);
message.setHeader(CaffeineConstants.ACTION_HAS_RESULT, oldValue != null || result != null);
if (oldValue != null) {
message.setHeader(CaffeineConstants.OLD_VALUE, oldValue);
}
if (result != null) {
message.setBody(result);
}
}
}
代码示例来源:origin: org.apache.camel/camel-test
public void process(Exchange exchange) {
Message in = exchange.getIn();
in.setBody(body);
for (Map.Entry<String, Object> entry : headers.entrySet()) {
in.setHeader(entry.getKey(), entry.getValue());
}
}
});
代码示例来源:origin: org.apache.camel/camel-hazelcast
public static void setListenerHeaders(Exchange ex, String listenerType, String listenerAction) {
ex.getIn().setHeader(HazelcastConstants.LISTENER_ACTION, listenerAction);
ex.getIn().setHeader(HazelcastConstants.LISTENER_TYPE, listenerType);
ex.getIn().setHeader(HazelcastConstants.LISTENER_TIME, new Date().getTime());
}
代码示例来源:origin: org.apache.camel/camel-consul
protected void setBodyAndResult(Message message, Object body, boolean result) throws Exception {
message.setHeader(ConsulConstants.CONSUL_RESULT, result);
if (body != null) {
message.setBody(body);
}
}
代码示例来源:origin: org.apache.camel/camel-test
/**
* Creates an exchange with the given body
*/
protected Exchange createExchangeWithBody(CamelContext camelContext, Object body) {
Exchange exchange = new DefaultExchange(camelContext);
Message message = exchange.getIn();
message.setHeader("testClass", getClass().getName());
message.setBody(body);
return exchange;
}
代码示例来源:origin: nz.ac.auckland.morc/morc
@Override
public void process(Exchange exchange) {
if (exchange == null) return;
exchange.getIn().setHeader(Exchange.HTTP_PATH, path);
logger.debug("Setting HTTP path to {}", path);
}
代码示例来源:origin: org.apache.camel/camel-infinispan
private void setResult(Message message, Object result) {
String resultHeader = message.getHeader(InfinispanConstants.RESULT_HEADER, configuration::getResultHeader, String.class);
if (resultHeader != null) {
message.setHeader(resultHeader, result);
} else {
message.setBody(result);
}
}
}
代码示例来源:origin: org.apache.camel/camel-test
/**
* Creates an exchange with the given body
*/
protected Exchange createExchangeWithBody(CamelContext camelContext, Object body) {
Exchange exchange = new DefaultExchange(camelContext);
Message message = exchange.getIn();
message.setHeader("testName", getName());
message.setHeader("testClass", getClass().getName());
message.setBody(body);
return exchange;
}
代码示例来源:origin: nz.ac.auckland.morc/morc
@Override
public void process(Exchange exchange) throws Exception {
logger.debug("Setting Content-Type header to {}", contentType);
exchange.getIn().setHeader(Exchange.CONTENT_TYPE, contentType);
}
}
代码示例来源:origin: org.metaeffekt.dcc/dcc-agent-core
/**
* {@inheritDoc}
*/
protected void doHandleFailedExchange(Exchange exchange, Throwable t) {
final int errorCode = mapToHttpErrorCode(t);
exchange.getOut().setBody(String.format("Exception [%s] occured. Message was [%s]", t.getClass().getName(), t.getMessage()));
exchange.getOut().setHeader(Exchange.HTTP_RESPONSE_CODE, (int) errorCode);
}
代码示例来源:origin: org.apache.camel/camel-mongodb
public Exchange createMongoDbExchange(DBObject dbObj) {
Exchange exchange = super.createExchange();
Message message = exchange.getIn();
message.setHeader(MongoDbConstants.DATABASE, database);
message.setHeader(MongoDbConstants.COLLECTION, collection);
message.setHeader(MongoDbConstants.FROM_TAILABLE, true);
message.setBody(dbObj);
return exchange;
}
代码示例来源:origin: org.apache.camel/camel-example-loan-broker
public void process(Exchange exchange) throws Exception {
String ssn = exchange.getIn().getHeader(Constants.PROPERTY_SSN, String.class);
int score = (int) (Math.random() * 600 + 300);
int hlength = (int) (Math.random() * 19 + 1);
exchange.getOut().setHeader(Constants.PROPERTY_SCORE, score);
exchange.getOut().setHeader(Constants.PROPERTY_HISTORYLENGTH, hlength);
exchange.getOut().setHeader(Constants.PROPERTY_SSN, ssn);
}
代码示例来源:origin: org.apache.camel/camel-mongodb
private void processAndTransferResult(Object result, Exchange exchange, MongoDbOperation operation) {
// determine where to set the WriteResult: as the OUT body or as an IN message header
if (isWriteOperation(operation) && endpoint.isWriteResultAsHeader()) {
exchange.getOut().setHeader(MongoDbConstants.WRITERESULT, result);
} else {
exchange.getOut().setBody(result);
}
}
代码示例来源:origin: org.apache.camel/camel-couchdb
public Exchange createExchange(String seq, String id, JsonObject obj, boolean deleted) {
Exchange exchange = super.createExchange();
exchange.getIn().setHeader(CouchDbConstants.HEADER_DATABASE, database);
exchange.getIn().setHeader(CouchDbConstants.HEADER_SEQ, seq);
exchange.getIn().setHeader(CouchDbConstants.HEADER_DOC_ID, id);
exchange.getIn().setHeader(CouchDbConstants.HEADER_DOC_REV, obj.get("_rev").getAsString());
exchange.getIn().setHeader(CouchDbConstants.HEADER_METHOD, deleted ? "DELETE" : "UPDATE");
exchange.getIn().setBody(obj);
return exchange;
}
代码示例来源:origin: OpenNMS/opennms
@Override
public void postProcess(Exchange exchange) {
// Copy the value of the correlation id header from the in to the out
exchange.getOut().setHeader(AmazonSQSRPCConstants.AWS_SQS_CORRELATION_ID_HEADER,
exchange.getIn().getHeader(AmazonSQSRPCConstants.AWS_SQS_CORRELATION_ID_HEADER));
}
}
内容来源于网络,如有侵权,请联系作者删除!