-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Solace Read connector: UnboundedSource and UnboundedReader (#31636)
* Add interfaces for broker-helper classes * Add UnboundedSolaceReader and UnboundedSolaceSource
- Loading branch information
Showing
9 changed files
with
523 additions
and
3 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
59 changes: 59 additions & 0 deletions
59
sdks/java/io/solace/src/main/java/org/apache/beam/sdk/io/solace/broker/MessageReceiver.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,59 @@ | ||
/* | ||
* 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.beam.sdk.io.solace.broker; | ||
|
||
import com.solacesystems.jcsmp.BytesXMLMessage; | ||
import java.io.IOException; | ||
|
||
/** | ||
* Interface for receiving messages from a Solace broker. | ||
* | ||
* <p>Implementations of this interface are responsible for managing the connection to the broker | ||
* and for receiving messages from the broker. | ||
*/ | ||
public interface MessageReceiver { | ||
/** | ||
* Starts the message receiver. | ||
* | ||
* <p>This method is called in the {@link | ||
* org.apache.beam.sdk.io.solace.read.UnboundedSolaceReader#start()} method. | ||
*/ | ||
void start(); | ||
|
||
/** | ||
* Returns {@literal true} if the message receiver is closed, {@literal false} otherwise. | ||
* | ||
* <p>A message receiver is closed when it is no longer able to receive messages. | ||
*/ | ||
boolean isClosed(); | ||
|
||
/** | ||
* Receives a message from the broker. | ||
* | ||
* <p>This method will block until a message is received. | ||
*/ | ||
BytesXMLMessage receive() throws IOException; | ||
|
||
/** | ||
* Test clients may return {@literal true} to signal that all expected messages have been pulled | ||
* and the test may complete. Real clients should always return {@literal false}. | ||
*/ | ||
default boolean isEOF() { | ||
return false; | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
sdks/java/io/solace/src/main/java/org/apache/beam/sdk/io/solace/broker/SempClient.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,49 @@ | ||
/* | ||
* 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.beam.sdk.io.solace.broker; | ||
|
||
import com.solacesystems.jcsmp.Queue; | ||
import java.io.IOException; | ||
import java.io.Serializable; | ||
|
||
/** | ||
* This interface defines methods for interacting with a Solace message broker using the Solace | ||
* Element Management Protocol (SEMP). SEMP provides a way to manage and monitor various aspects of | ||
* the broker, including queues and topics. | ||
*/ | ||
public interface SempClient extends Serializable { | ||
|
||
/** | ||
* Determines if the specified queue is non-exclusive. In Solace, non-exclusive queues allow | ||
* multiple consumers to receive messages from the queue. | ||
*/ | ||
boolean isQueueNonExclusive(String queueName) throws IOException; | ||
|
||
/** | ||
* This is only called when a user requests to read data from a topic. This method creates a new | ||
* queue on the Solace broker and associates it with the specified topic. This ensures that | ||
* messages published to the topic are delivered to the queue, allowing consumers to receive them. | ||
*/ | ||
Queue createQueueForTopic(String queueName, String topicName) throws IOException; | ||
|
||
/** | ||
* Retrieves the size of the backlog (in bytes) for the specified queue. The backlog represents | ||
* the amount of data in messages that are waiting to be delivered to consumers. | ||
*/ | ||
long getBacklogBytes(String queueName) throws IOException; | ||
} |
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
50 changes: 50 additions & 0 deletions
50
sdks/java/io/solace/src/main/java/org/apache/beam/sdk/io/solace/broker/SessionService.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,50 @@ | ||
/* | ||
* 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.beam.sdk.io.solace.broker; | ||
|
||
import java.io.Serializable; | ||
|
||
/** | ||
* The SessionService interface provides a set of methods for managing a session with the Solace | ||
* messaging system. It allows for establishing a connection, creating a message-receiver object, | ||
* checking if the connection is closed or not, and gracefully closing the session. | ||
*/ | ||
public interface SessionService extends Serializable { | ||
|
||
/** | ||
* Establishes a connection to the service. This could involve providing connection details like | ||
* host, port, VPN name, username, and password. | ||
*/ | ||
void connect(); | ||
|
||
/** Gracefully closes the connection to the service. */ | ||
void close(); | ||
|
||
/** | ||
* Checks whether the connection to the service is currently closed. This method is called when an | ||
* `UnboundedSolaceReader` is starting to read messages - a session will be created if this | ||
* returns true. | ||
*/ | ||
boolean isClosed(); | ||
|
||
/** | ||
* Creates a MessageReceiver object for receiving messages from Solace. Typically, this object is | ||
* created from the session instance. | ||
*/ | ||
MessageReceiver createReceiver(); | ||
} |
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.