Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -86,7 +86,7 @@ protected String description() {
if (messageFrequency != null) {
return "1 Exchange per " + getMessageFrequency() + " messages received";
} else {
return "1 Exchange per " + TimeUtils.printDuration(TimeUtils.toDuration(samplePeriod));
return "1 Exchange per " + getSamplePeriod() + " millis";
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Properties;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

Expand Down Expand Up @@ -100,6 +101,17 @@ public void run() {
executor.shutdownNow();
}

@Test
public void testSamplingWithPropertyPlaceholder() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMinimumMessageCount(1);
mock.setResultWaitTime(3000);

template.sendBody("direct:sample-placeholder", "<message>placeholder test</message>");

mock.assertIsSatisfied();
}

@Test
public void testSamplingUsingMessageFrequency() throws Exception {
long totalMessages = 100;
Expand Down Expand Up @@ -156,6 +168,13 @@ private void validateDroppedExchanges(List<Exchange> sentExchanges, int expected
assertEquals(expectedNotDroppedCount, notDropped);
}

@Override
protected Properties useOverridePropertiesWithPropertiesComponent() {
Properties props = new Properties();
props.put("sample.period", "1000");
return props;
}

@Override
protected RouteBuilder createRouteBuilder() {
return new RouteBuilder() {
Expand All @@ -171,6 +190,8 @@ public void configure() {

from("direct:sample-messageFrequency-via-dsl").sample().sampleMessageFrequency(5).to("mock:result");

from("direct:sample-placeholder").sample("{{sample.period}}").to("mock:result");

// END SNIPPET: e1
}
};
Expand Down
Loading