Skip to content
This repository was archived by the owner on Dec 9, 2025. It is now read-only.

Commit 33e9948

Browse files
author
sachin-maheshwari
authored
Merge pull request #51 from appirio-tech/dev
JIRA-Plot-130, hard cut legacy kafka publishing
2 parents c7a37bf + 62d8a8a commit 33e9948

File tree

4 files changed

+39
-18
lines changed

4 files changed

+39
-18
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ workflows:
146146
context : org-global
147147
filters:
148148
branches:
149-
only: [dev, 'feature/jira-plat-28']
149+
only: [dev, 'feature/jira-plat-152']
150150
# Production build is executed on "master" branch only.
151151
- "build-prod":
152152
context : org-global

src/main/java/com/appirio/tech/core/service/identity/IdentityApplication.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,10 @@ public void run(IdentityConfiguration configuration, Environment environment) th
159159

160160
// Setup Events
161161
EventProducer eventProducer;
162+
163+
// JIRA-Plat-130, stop initializing the zookeeper
164+
eventProducer = null;
165+
/* JIRA-Plat-130
162166
try {
163167
eventProducer = configuration.getEventSystem().getProducerFactory().createProducer();
164168
EventClientManager eventClientManager = new EventClientManager(eventProducer);
@@ -169,7 +173,7 @@ public void run(IdentityConfiguration configuration, Environment environment) th
169173
} catch(Exception e) {
170174
logger.error("Exception: "+e.getMessage());
171175
throw e;
172-
}
176+
} */
173177

174178
// Application context
175179
Utils.setApplicationContext(configuration.getContext());

src/main/java/com/appirio/tech/core/service/identity/resource/UserResource.java

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1898,25 +1898,36 @@ protected void publishEvent(String topic, Object payload) {
18981898
return;
18991899
if(topic==null)
19001900
throw new IllegalArgumentException("topic must be specified.");
1901-
if(this.eventProducer==null)
1902-
throw new IllegalStateException("eventProducer must be configured.");
1901+
if(this.eventProducer==null) {
1902+
// JIRA-Plat-130
1903+
logger.info("eventProducer null, hard cut to publish on leagcy kafka");
1904+
if (topic != null) {
1905+
logger.debug(String.format("Publishing an event to '%s'.", topic));
1906+
}
1907+
//throw new IllegalStateException("eventProducer must be configured.");
1908+
1909+
try {
1910+
this.fireEvent(payload);
1911+
} catch (Exception e) {
1912+
logger.error(String.format("Failed to fire an event to event bus. topic: %s", topic), e);
1913+
}
1914+
return;
1915+
}
19031916
if(this.objectMapper==null)
19041917
throw new IllegalStateException("objectMapper must be configured.");
19051918

19061919
try {
19071920
logger.debug(String.format("Publishing an event to '%s'.", topic));
19081921
String strPayload = this.objectMapper.writeValueAsString(payload);
1922+
1923+
/* JIRA-Plat-130
19091924
try {
19101925
this.eventProducer.publish(topic, strPayload);
19111926
} catch (Exception e) {
19121927
logger.error(String.format("Failed to publish an event. topic: %s, payload: %s", topic, strPayload), e);
19131928
}
1929+
*/
19141930

1915-
try {
1916-
this.fireEvent(payload);
1917-
} catch (Exception e) {
1918-
logger.error(String.format("Failed to fire an event to event bus. topic: %s, payload: %s", topic, strPayload), e);
1919-
}
19201931

19211932
} catch (Exception e) {
19221933
logger.error(String.format("Failed to convert the payload - %s", payload), e);

src/test/java/com/appirio/tech/core/service/identity/resource/UserResourceTest.java

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -746,10 +746,13 @@ public void testCreateObject_WithUser(User userdata) throws Exception {
746746
user.isReferralProgramCampaign() ? times(1) : never()
747747
).validateReferral(user.getUtmSource());
748748

749+
/*
750+
//jira-plat-130
749751
verify(eventProducer).publish("event.user.created", "payload");
750752
verify(eventProducer,
751753
isUserActive? never() : times(1)).
752754
publish("event.notification.send", "payload");
755+
*/
753756
verify(objectMapper).writeValueAsString(user);
754757
}
755758

@@ -1847,9 +1850,12 @@ public void testActivateUser() throws Exception {
18471850
// verify
18481851
verify(userDao).findUserById(userId);
18491852
verify(userDao).activate(user);
1850-
verify(eventProducer).publish("event.user.activated", "payload");
1851-
verify(eventProducer).publish("event.notification.send", "payload"); // welcome mail
1852-
verify(objectMapper).writeValueAsString(user);
1853+
/*
1854+
//jira-plat-130
1855+
verify(eventProducer).publish("event.user.activated", "payload");
1856+
verify(eventProducer).publish("event.notification.send", "payload"); // welcome mail
1857+
*/
1858+
verify(objectMapper).writeValueAsString(user);
18531859
}
18541860

18551861
@Test
@@ -1937,7 +1943,7 @@ public void testSendActivationCode() throws Exception {
19371943
verify(cacheService).put(cacheKey, user.getCredential().getActivationCode(), testee.getResendActivationCodeExpirySeconds());
19381944

19391945
verify(param).getOptionString(optionKey);
1940-
verify(eventProducer).publish("event.notification.send", "payload");
1946+
// jira-plat-130 verify(eventProducer).publish("event.notification.send", "payload");
19411947
}
19421948

19431949
@Test
@@ -2247,7 +2253,7 @@ public void testUpdateHandle() throws Exception {
22472253
// verify
22482254
verify(userDao).findUserById(userId);
22492255
verify(userDao).updateHandle(user);
2250-
verify(eventProducer).publish("event.user.updated", "payload");
2256+
// jira-plat-130 verify(eventProducer).publish("event.user.updated", "payload");
22512257
verify(objectMapper).writeValueAsString(user);
22522258
verify(authUser, atLeastOnce()).getUserId();
22532259
verify(param, atLeastOnce()).getParam();
@@ -2517,7 +2523,7 @@ public void testUpdatePrimaryEmail() throws Exception {
25172523
// verify
25182524
verify(userDao).findUserById(userId);
25192525
verify(userDao).updatePrimaryEmail(user);
2520-
verify(eventProducer).publish("event.user.updated", "payload");
2526+
// jira-plat-130 verify(eventProducer).publish("event.user.updated", "payload");
25212527
verify(objectMapper).writeValueAsString(user);
25222528
verify(authUser, atLeastOnce()).getUserId();
25232529
verify(param, atLeastOnce()).getParam();
@@ -3026,13 +3032,13 @@ public void testUpdateStatus(String newStatus, String comment, User user) throws
30263032
topic = "event.user.activated";
30273033
else
30283034
topic = "event.user.deactivated";
3029-
verify(eventProducer).publish(topic, "payload");
3035+
// jira-plat-130 verify(eventProducer).publish(topic, "payload");
30303036

30313037
if(MemberStatus.UNVERIFIED == MemberStatus.getByValue(oldStatus) &&
30323038
MemberStatus.ACTIVE == MemberStatus.getByValue(newStatus) ) {
3033-
verify(eventProducer).publish("event.notification.send", "payload");
3039+
// jira-plat-130 verify(eventProducer).publish("event.notification.send", "payload");
30343040
} else {
3035-
verify(eventProducer, never()).publish(eq("event.notification.send"), anyString());
3041+
// jira-plat-130 verify(eventProducer, never()).publish(eq("event.notification.send"), anyString());
30363042
}
30373043

30383044
verify(objectMapper).writeValueAsString(user);

0 commit comments

Comments
 (0)