-
Notifications
You must be signed in to change notification settings - Fork 640
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
[Feature #562] support cloudevents api in eventmesh-connector-api module #578
Merged
Merged
Changes from 8 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
fb84d90
[Feature #564] Support CloudEvents protocols for pub/sub in EventMesh…
xwm1992 4e55912
support cloudevents api in eventmesh-connector-api module
xwm1992 e602004
Merge branch 'develop' of https://github.com/apache/incubator-eventme…
xwm1992 9adb5e9
Merge branch 'develop' of https://github.com/apache/incubator-eventme…
xwm1992 670c2f2
fix checkStyle
xwm1992 691bcb3
fix checkStyle
xwm1992 b6a4613
fix checkStyle
xwm1992 0ac6d4f
1.support LifeCycle.java
xwm1992 2239a65
fix remove the extra blank line
xwm1992 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
25 changes: 25 additions & 0 deletions
25
...n/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/AsyncConsumeContext.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,25 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.eventmesh.api; | ||
|
||
|
||
public abstract class AsyncConsumeContext { | ||
|
||
public abstract void commit(EventMeshAction action); | ||
|
||
} |
37 changes: 37 additions & 0 deletions
37
...-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/EventListener.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,37 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.eventmesh.api; | ||
|
||
|
||
import io.cloudevents.CloudEvent; | ||
|
||
/** | ||
* Event listener, registered for consume messages by consumer. | ||
* | ||
* <p> | ||
* <strong> | ||
* Thread safe requirements: this interface will be invoked by multi threads, | ||
* so users should keep thread safe during the consume process. | ||
* </strong> | ||
* </p> | ||
*/ | ||
public interface EventListener { | ||
|
||
void consume(final CloudEvent cloudEvent, final AsyncConsumeContext context); | ||
|
||
} |
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
36 changes: 36 additions & 0 deletions
36
...ctor-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/LifeCycle.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,36 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.eventmesh.api; | ||
|
||
import org.apache.eventmesh.api.consumer.Consumer; | ||
import org.apache.eventmesh.api.producer.Producer; | ||
|
||
/** | ||
* The {@code LifeCycle} defines a lifecycle interface for a OMS related service endpoint, | ||
* like {@link Producer}, {@link Consumer}, and so on. | ||
*/ | ||
public interface LifeCycle { | ||
|
||
boolean isStarted(); | ||
|
||
boolean isClosed(); | ||
|
||
void start(); | ||
|
||
void shutdown(); | ||
} |
33 changes: 33 additions & 0 deletions
33
...r-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/SendCallback.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,33 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.eventmesh.api; | ||
|
||
import org.apache.eventmesh.api.exception.OnExceptionContext; | ||
import org.apache.eventmesh.api.producer.Producer; | ||
|
||
import io.cloudevents.CloudEvent; | ||
|
||
/** | ||
* Call back interface used in {@link Producer#sendAsync(CloudEvent, SendCallback)}. | ||
*/ | ||
public interface SendCallback { | ||
|
||
void onSuccess(final SendResult sendResult); | ||
|
||
void onException(final OnExceptionContext context); | ||
} |
45 changes: 45 additions & 0 deletions
45
...tor-plugin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/SendResult.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,45 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.eventmesh.api; | ||
|
||
public class SendResult { | ||
private String messageId; | ||
|
||
private String topic; | ||
|
||
public String getMessageId() { | ||
return messageId; | ||
} | ||
|
||
public void setMessageId(String messageId) { | ||
this.messageId = messageId; | ||
} | ||
|
||
public String getTopic() { | ||
return topic; | ||
} | ||
|
||
public void setTopic(String topic) { | ||
this.topic = topic; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "SendResult[topic=" + topic + ", messageId=" + messageId + ']'; | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
...gin/eventmesh-connector-api/src/main/java/org/apache/eventmesh/api/consumer/Consumer.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,46 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.eventmesh.api.consumer; | ||
|
||
import org.apache.eventmesh.api.AbstractContext; | ||
import org.apache.eventmesh.api.EventListener; | ||
import org.apache.eventmesh.api.LifeCycle; | ||
import org.apache.eventmesh.spi.EventMeshExtensionType; | ||
import org.apache.eventmesh.spi.EventMeshSPI; | ||
|
||
import java.util.List; | ||
import java.util.Properties; | ||
|
||
import io.cloudevents.CloudEvent; | ||
|
||
|
||
|
||
/** | ||
* Consumer Interface. | ||
*/ | ||
@EventMeshSPI(isSingleton = false, eventMeshExtensionType = EventMeshExtensionType.CONNECTOR) | ||
public interface Consumer extends LifeCycle { | ||
|
||
void init(Properties keyValue) throws Exception; | ||
|
||
void updateOffset(List<CloudEvent> cloudEvents, AbstractContext context); | ||
|
||
void subscribe(String topic, final EventListener listener) throws Exception; | ||
|
||
void unsubscribe(String topic); | ||
} |
38 changes: 38 additions & 0 deletions
38
...ector-api/src/main/java/org/apache/eventmesh/api/exception/ConnectorRuntimeException.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,38 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.eventmesh.api.exception; | ||
|
||
public class ConnectorRuntimeException extends RuntimeException { | ||
|
||
public ConnectorRuntimeException() { | ||
|
||
} | ||
|
||
public ConnectorRuntimeException(String message) { | ||
super(message); | ||
} | ||
|
||
public ConnectorRuntimeException(Throwable throwable) { | ||
super(throwable); | ||
} | ||
|
||
public ConnectorRuntimeException(String message, Throwable throwable) { | ||
super(message, throwable); | ||
} | ||
|
||
} |
57 changes: 57 additions & 0 deletions
57
...sh-connector-api/src/main/java/org/apache/eventmesh/api/exception/OnExceptionContext.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,57 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.eventmesh.api.exception; | ||
|
||
|
||
public class OnExceptionContext { | ||
|
||
private String messageId; | ||
|
||
private String topic; | ||
|
||
/** | ||
* Detailed exception stack information. | ||
*/ | ||
private ConnectorRuntimeException exception; | ||
|
||
|
||
public String getMessageId() { | ||
return messageId; | ||
} | ||
|
||
public void setMessageId(String messageId) { | ||
this.messageId = messageId; | ||
} | ||
|
||
public String getTopic() { | ||
return topic; | ||
} | ||
|
||
public void setTopic(String topic) { | ||
this.topic = topic; | ||
} | ||
|
||
|
||
public ConnectorRuntimeException getException() { | ||
return exception; | ||
} | ||
|
||
public void setException(ConnectorRuntimeException exception) { | ||
this.exception = exception; | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I'll remove the extra blank line.