Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update http push request and adaptor #606

Merged
merged 43 commits into from
Nov 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
fb84d90
[Feature #564] Support CloudEvents protocols for pub/sub in EventMesh…
xwm1992 Oct 28, 2021
4e55912
support cloudevents api in eventmesh-connector-api module
xwm1992 Nov 1, 2021
e602004
Merge branch 'develop' of https://github.com/apache/incubator-eventme…
xwm1992 Nov 1, 2021
9adb5e9
Merge branch 'develop' of https://github.com/apache/incubator-eventme…
xwm1992 Nov 1, 2021
670c2f2
fix checkStyle
xwm1992 Nov 1, 2021
691bcb3
fix checkStyle
xwm1992 Nov 1, 2021
b6a4613
fix checkStyle
xwm1992 Nov 1, 2021
0ac6d4f
1.support LifeCycle.java
xwm1992 Nov 1, 2021
2239a65
fix remove the extra blank line
xwm1992 Nov 1, 2021
086f4e6
Merge branch 'cloudevents' of https://github.com/apache/incubator-eve…
xwm1992 Nov 2, 2021
308dfd7
support cloudEvents
xwm1992 Nov 2, 2021
f288ae2
Add files via upload
qqeasonchen Nov 3, 2021
09b9a22
Update README.md
qqeasonchen Nov 3, 2021
f0f3108
support cloudEvents
xwm1992 Nov 8, 2021
0290837
support cloudEvents
xwm1992 Nov 9, 2021
90a28cc
[ISSUE #580] Add checkstyle gradle plugin (#581)
ruanwenjun Nov 10, 2021
4425aaf
support cloudEvents
xwm1992 Nov 10, 2021
0dce0ca
support cloudevents
xwm1992 Nov 10, 2021
9251e07
update wechat-official qr code
xwm1992 Nov 11, 2021
ff1c247
update mesh-helper qr code
xwm1992 Nov 11, 2021
00994c3
Add files via upload
qqeasonchen Nov 11, 2021
bcf0337
update README.md
xwm1992 Nov 11, 2021
4938cd7
update README.md
xwm1992 Nov 11, 2021
61d0410
Update .asf.yaml
qqeasonchen Nov 11, 2021
3166325
support cloudEvents
xwm1992 Nov 11, 2021
bbd3535
support cloudEvents
xwm1992 Nov 12, 2021
de99c54
Merge branch 'cloudevents' of https://github.com/apache/incubator-eve…
xwm1992 Nov 12, 2021
ceaf33b
[ISSUE #588] Fix typo in README.md (#589)
nichozhan Nov 15, 2021
468386c
Merge branch 'cloudevents' of https://github.com/apache/incubator-eve…
xwm1992 Nov 16, 2021
d2d2b7d
support cloudEvents
xwm1992 Nov 16, 2021
46f973d
[Bug #590] Consumer subscription topic is invalid (#590) (#592)
hagsyn Nov 16, 2021
cf8433a
support cloudEvents adaptor
xwm1992 Nov 16, 2021
18310a1
[Feature #562] Implement CloudEvents adaptor
xwm1992 Nov 17, 2021
3149552
Merge branch 'develop' of https://github.com/apache/incubator-eventme…
xwm1992 Nov 17, 2021
d7ddac8
Merge branch 'cloudevents' of https://github.com/apache/incubator-eve…
xwm1992 Nov 17, 2021
c534985
[Feature #562] Implement EventMeshMessage protocol adaptor
xwm1992 Nov 18, 2021
024e462
Merge branch 'cloudevents' of https://github.com/apache/incubator-eve…
xwm1992 Nov 18, 2021
f096294
supplement apache header
xwm1992 Nov 18, 2021
46d8a51
Merge branch 'cloudevents' of https://github.com/apache/incubator-eve…
xwm1992 Nov 19, 2021
0f34e98
1.update package name
xwm1992 Nov 19, 2021
2099b9e
Merge branch 'cloudevents' of https://github.com/apache/incubator-eve…
xwm1992 Nov 22, 2021
c698617
1.update http push request
xwm1992 Nov 23, 2021
42552ee
Merge branch 'cloudevents' of https://github.com/apache/incubator-eve…
xwm1992 Nov 23, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,17 @@
import org.apache.eventmesh.common.protocol.http.common.RequestCode;
import org.apache.eventmesh.common.protocol.tcp.Header;
import org.apache.eventmesh.common.protocol.tcp.Package;
import org.apache.eventmesh.common.utils.JsonUtils;
import org.apache.eventmesh.protocol.api.ProtocolAdaptor;
import org.apache.eventmesh.protocol.api.exception.ProtocolHandleException;
import org.apache.eventmesh.protocol.cloudevents.resolver.http.SendMessageBatchProtocolResolver;
import org.apache.eventmesh.protocol.cloudevents.resolver.http.SendMessageBatchV2ProtocolResolver;
import org.apache.eventmesh.protocol.cloudevents.resolver.http.SendMessageRequestProtocolResolver;
import org.apache.eventmesh.protocol.cloudevents.resolver.tcp.TcpMessageProtocolResolver;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
* CloudEvents protocol adaptor, used to transform CloudEvents message to CloudEvents message.
Expand Down Expand Up @@ -93,9 +96,18 @@ public List<CloudEvent> toBatchCloudEvent(ProtocolTransportObject protocol)
public ProtocolTransportObject fromCloudEvent(CloudEvent cloudEvent) throws ProtocolHandleException {
String protocolDesc = cloudEvent.getExtension(Constants.PROTOCOL_DESC).toString();
if (StringUtils.equals("http", protocolDesc)) {
// todo: return command, set cloudEvent.getData() to content?
return null;
// return new String(cloudEvent.getData().toBytes(), StandardCharsets.UTF_8);
HttpCommand httpCommand = new HttpCommand();
Body body = new Body() {
final Map<String, Object> map = new HashMap<>();
@Override
public Map<String, Object> toMap() {
map.put("content", JsonUtils.serialize(cloudEvent));
return map;
}
};
body.toMap();
httpCommand.setBody(body);
return httpCommand;
} else if (StringUtils.equals("tcp", protocolDesc)) {
Package pkg = new Package();
pkg.setBody(cloudEvent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.apache.eventmesh.common.protocol.http.common.RequestCode;
import org.apache.eventmesh.common.protocol.tcp.Header;
import org.apache.eventmesh.common.protocol.tcp.Package;
import org.apache.eventmesh.common.utils.JsonUtils;
import org.apache.eventmesh.protocol.api.ProtocolAdaptor;
import org.apache.eventmesh.protocol.api.exception.ProtocolHandleException;
import org.apache.eventmesh.protocol.meshmessage.resolver.http.SendMessageBatchProtocolResolver;
Expand All @@ -33,7 +34,10 @@

import org.apache.commons.lang3.StringUtils;

import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import io.cloudevents.CloudEvent;

Expand Down Expand Up @@ -90,9 +94,18 @@ public ProtocolTransportObject fromCloudEvent(CloudEvent cloudEvent) throws Prot
String protocolDesc = cloudEvent.getExtension(Constants.PROTOCOL_DESC).toString();

if (StringUtils.equals("http", protocolDesc)) {
// todo: return command, set cloudEvent.getData() to content?
return null;
// return new String(cloudEvent.getData().toBytes(), StandardCharsets.UTF_8);
HttpCommand httpCommand = new HttpCommand();
Body body = new Body() {
final Map<String, Object> map = new HashMap<>();
@Override
public Map<String, Object> toMap() {
map.put("content", new String(cloudEvent.getData().toBytes(), StandardCharsets.UTF_8));
return map;
}
};
body.toMap();
httpCommand.setBody(body);
return httpCommand;
} else if (StringUtils.equals("tcp", protocolDesc)) {
return TcpMessageProtocolResolver.buildEventMeshMessage(cloudEvent);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import io.cloudevents.CloudEvent;
import io.cloudevents.core.builder.CloudEventBuilder;
import org.apache.eventmesh.common.Constants;
import org.apache.eventmesh.common.protocol.http.HttpCommand;
import org.apache.eventmesh.common.utils.IPUtils;
import org.apache.eventmesh.common.protocol.ProtocolTransportObject;
import org.apache.eventmesh.common.utils.RandomStringUtils;
Expand Down Expand Up @@ -120,12 +121,9 @@ public void tryHTTPRequest() {

ProtocolAdaptor<ProtocolTransportObject> protocolAdaptor = ProtocolPluginFactory.getProtocolAdaptor(protocolType);

// todo
ProtocolTransportObject protocolTransportObject =
protocolAdaptor.fromCloudEvent(handleMsgContext.getEvent());

// content =
// new String(handleMsgContext.getEvent().getData().toBytes(), EventMeshConstants.DEFAULT_CHARSET);
content = ((HttpCommand) protocolTransportObject).getBody().toMap().get("content").toString();
} catch (Exception ex) {
return;
}
Expand Down