Skip to content

Commit

Permalink
Merge branch 'main' into main-2-11
Browse files Browse the repository at this point in the history
  • Loading branch information
scottf authored Nov 1, 2024
2 parents aa97394 + 10db91d commit 9cf1e16
Show file tree
Hide file tree
Showing 6 changed files with 1 addition and 58 deletions.
2 changes: 1 addition & 1 deletion src/main/java/io/nats/client/ConnectionListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,4 @@ public String toString() {
* @param type the type of event that has occurred
*/
void connectionEvent(Connection conn, Events type);
}
}
10 changes: 0 additions & 10 deletions src/main/java/io/nats/client/StreamContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -163,16 +163,6 @@ public interface StreamContext {
*/
MessageInfo getLastMessage(String subject) throws IOException, JetStreamApiException;

/**
* Get MessageInfo for the first message of the subject.
* @param subject the subject to get the first message for.
* @return The MessageInfo
* @throws IOException covers various communication issues with the NATS
* server such as timeout or interruption
* @throws JetStreamApiException the request had an error related to the data
*/
MessageInfo getFirstMessage(String subject) throws IOException, JetStreamApiException;

/**
* Get MessageInfo for the message of the message sequence
* is equal to or greater the requested sequence for the subject.
Expand Down
24 changes: 0 additions & 24 deletions src/main/java/io/nats/client/impl/NatsJetStreamManagement.java
Original file line number Diff line number Diff line change
Expand Up @@ -286,30 +286,6 @@ public MessageInfo getLastMessage(String streamName, String subject) throws IOEx
return _getMessage(streamName, MessageGetRequest.lastForSubject(subject));
}

/**
* {@inheritDoc}
*/
@Override
public MessageInfo getFirstMessage(String streamName, String subject) throws IOException, JetStreamApiException {
return _getMessage(streamName, MessageGetRequest.firstForSubject(subject));
}

/**
* {@inheritDoc}
*/
@Override
public MessageInfo getFirstMessage(String streamName, ZonedDateTime startTime) throws IOException, JetStreamApiException {
return _getMessage(streamName, MessageGetRequest.firstForStartTime(startTime));
}

/**
* {@inheritDoc}
*/
@Override
public MessageInfo getFirstMessage(String streamName, ZonedDateTime startTime, String subject) throws IOException, JetStreamApiException {
return _getMessage(streamName, MessageGetRequest.firstForStartTimeAndSubject(startTime, subject));
}

/**
* {@inheritDoc}
*/
Expand Down
8 changes: 0 additions & 8 deletions src/main/java/io/nats/client/impl/NatsStreamContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -147,14 +147,6 @@ public MessageInfo getLastMessage(String subject) throws IOException, JetStreamA
return jsm.getLastMessage(streamName, subject);
}

/**
* {@inheritDoc}
*/
@Override
public MessageInfo getFirstMessage(String subject) throws IOException, JetStreamApiException {
return jsm.getFirstMessage(streamName, subject);
}

/**
* {@inheritDoc}
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1292,10 +1292,6 @@ private void validateGetMessage(JetStreamManagement jsm, TestingStreamContainer
assertMessageInfo(tsc, 1, 2, jsm.getNextMessage(tsc.stream, -1, tsc.subject(1)), beforeCreated);
assertMessageInfo(tsc, 0, 1, jsm.getNextMessage(tsc.stream, 0, tsc.subject(0)), beforeCreated);
assertMessageInfo(tsc, 1, 2, jsm.getNextMessage(tsc.stream, 0, tsc.subject(1)), beforeCreated);
assertMessageInfo(tsc, 0, 1, jsm.getFirstMessage(tsc.stream, tsc.subject(0)), beforeCreated);
assertMessageInfo(tsc, 1, 2, jsm.getFirstMessage(tsc.stream, tsc.subject(1)), beforeCreated);
assertMessageInfo(tsc, 0, 1, jsm.getFirstMessage(tsc.stream, beforeCreated), beforeCreated);
assertMessageInfo(tsc, 1, 2, jsm.getFirstMessage(tsc.stream, beforeCreated, tsc.subject(1)), beforeCreated);

assertMessageInfo(tsc, 0, 1, jsm.getNextMessage(tsc.stream, 1, tsc.subject(0)), beforeCreated);
assertMessageInfo(tsc, 1, 2, jsm.getNextMessage(tsc.stream, 1, tsc.subject(1)), beforeCreated);
Expand All @@ -1308,10 +1304,8 @@ private void validateGetMessage(JetStreamManagement jsm, TestingStreamContainer

assertStatus(10003, assertThrows(JetStreamApiException.class, () -> jsm.getMessage(tsc.stream, -1)));
assertStatus(10003, assertThrows(JetStreamApiException.class, () -> jsm.getMessage(tsc.stream, 0)));
assertStatus(10003, assertThrows(JetStreamApiException.class, () -> jsm.getFirstMessage(tsc.stream, DEFAULT_TIME)));
assertStatus(10037, assertThrows(JetStreamApiException.class, () -> jsm.getMessage(tsc.stream, 9)));
assertStatus(10037, assertThrows(JetStreamApiException.class, () -> jsm.getLastMessage(tsc.stream, "not-a-subject")));
assertStatus(10037, assertThrows(JetStreamApiException.class, () -> jsm.getFirstMessage(tsc.stream, "not-a-subject")));
assertStatus(10037, assertThrows(JetStreamApiException.class, () -> jsm.getNextMessage(tsc.stream, 9, tsc.subject(0))));
assertStatus(10037, assertThrows(JetStreamApiException.class, () -> jsm.getNextMessage(tsc.stream, 1, "not-a-subject")));
}
Expand Down
9 changes: 0 additions & 9 deletions src/test/java/io/nats/client/impl/SimplificationTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,6 @@ private static void _testStreamContext(JetStream js, TestingStreamContainer tsc,
MessageInfo mi = streamContext.getMessage(1);
assertEquals(1, mi.getSeq());

mi = streamContext.getFirstMessage(tsc.subject());
assertEquals(1, mi.getSeq());

mi = streamContext.getLastMessage(tsc.subject());
assertEquals(6, mi.getSeq());

Expand All @@ -123,12 +120,6 @@ private static void _testStreamContext(JetStream js, TestingStreamContainer tsc,

streamContext.purge(PurgeOptions.builder().sequence(5).build());
assertThrows(JetStreamApiException.class, () -> streamContext.getMessage(1));

mi = streamContext.getFirstMessage(tsc.subject());
assertEquals(5, mi.getSeq());

streamContext.purge();
assertThrows(JetStreamApiException.class, () -> streamContext.getFirstMessage(tsc.subject()));
}

static int FETCH_EPHEMERAL = 1;
Expand Down

0 comments on commit 9cf1e16

Please sign in to comment.