-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Sanjula Ganepola <Sanjula.Ganepola@ibm.com> Co-authored-by: Jonathan <42983653+jonnyz32@users.noreply.github.com>
- Loading branch information
1 parent
7af399d
commit 0114c7c
Showing
19 changed files
with
279 additions
and
179 deletions.
There are no files selected for viewing
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
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
40 changes: 40 additions & 0 deletions
40
camel/src/main/java/com/github/theprez/manzan/routes/dest/GooglePubSubDestination.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,40 @@ | ||
package com.github.theprez.manzan.routes.dest; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import org.apache.camel.CamelContext; | ||
import org.apache.camel.Exchange; | ||
import org.apache.camel.component.google.pubsub.GooglePubsubComponent; | ||
import org.apache.camel.component.google.pubsub.GooglePubsubConstants; | ||
|
||
import com.github.theprez.manzan.ManzanEventType; | ||
import com.github.theprez.manzan.routes.ManzanGenericCamelRoute; | ||
|
||
public class GooglePubSubDestination extends ManzanGenericCamelRoute { | ||
public GooglePubSubDestination(CamelContext context, final String _name, final String _projectId, final String _topicName, final String _serviceAccountKey, final String _format, final Map<String, String> _uriParams) { | ||
super(_name, "google-pubsub", _projectId + ":" + _topicName, _format, _uriParams, null); | ||
GooglePubsubComponent pubsub = context.getComponent("google-pubsub", GooglePubsubComponent.class); | ||
pubsub.setServiceAccountKey(_serviceAccountKey); | ||
pubsub.init(); | ||
pubsub.start(); | ||
} | ||
|
||
@Override | ||
protected void customPostProcess(Exchange exchange) { | ||
final ManzanEventType type = (ManzanEventType) exchange.getIn().getHeader(EVENT_TYPE); | ||
if (ManzanEventType.WATCH_MSG == type) { | ||
exchange.getIn().setHeader(GooglePubsubConstants.PUBLISH_TIME, getString(exchange, MSG_MESSAGE_TIMESTAMP)); | ||
} else if (ManzanEventType.WATCH_VLOG == type) { | ||
// exchange.getIn().setHeader(GooglePubsubConstants.PUBLISH_TIME, getString(exchange, LOG_TIMESTAMP)); | ||
} else if (ManzanEventType.WATCH_PAL == type) { | ||
// exchange.getIn().setHeader(GooglePubsubConstants.PUBLISH_TIME, getString(exchange, PAL_TIMESTAMP)); | ||
} | ||
|
||
Map<String, String> map = new HashMap<>(); | ||
for (Map.Entry<String, Object> entry : getDataMap(exchange).entrySet()) { | ||
map.put(entry.getKey(), entry.getValue().toString()); | ||
} | ||
exchange.getIn().setHeader(GooglePubsubConstants.ATTRIBUTES, map); | ||
} | ||
} |
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
Oops, something went wrong.