Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use database as MQ, change separator to +.
- Loading branch information
Showing
33 changed files
with
638 additions
and
348 deletions.
There are no files selected for viewing
56 changes: 0 additions & 56 deletions
56
...minservice/src/main/java/com/ctrip/apollo/adminservice/AdminServiceAutoConfiguration.java
This file was deleted.
Oops, something went wrong.
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
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
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
58 changes: 58 additions & 0 deletions
58
apollo-biz/src/main/java/com/ctrip/apollo/biz/entity/ReleaseMessage.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,58 @@ | ||
package com.ctrip.apollo.biz.entity; | ||
|
||
import java.util.Date; | ||
|
||
import javax.persistence.Column; | ||
import javax.persistence.Entity; | ||
import javax.persistence.GeneratedValue; | ||
import javax.persistence.Id; | ||
import javax.persistence.PrePersist; | ||
import javax.persistence.Table; | ||
|
||
/** | ||
* @author Jason Song(song_s@ctrip.com) | ||
*/ | ||
@Entity | ||
@Table(name = "ReleaseMessage") | ||
public class ReleaseMessage { | ||
@Id | ||
@GeneratedValue | ||
@Column(name = "Id") | ||
private long id; | ||
|
||
@Column(name = "Message", nullable = false) | ||
private String message; | ||
|
||
@Column(name = "DataChange_LastTime") | ||
private Date dataChangeLastModifiedTime; | ||
|
||
@PrePersist | ||
protected void prePersist() { | ||
if (this.dataChangeLastModifiedTime == null) { | ||
dataChangeLastModifiedTime = new Date(); | ||
} | ||
} | ||
|
||
public ReleaseMessage() { | ||
} | ||
|
||
public ReleaseMessage(String message) { | ||
this.message = message; | ||
} | ||
|
||
public long getId() { | ||
return id; | ||
} | ||
|
||
public void setId(long id) { | ||
this.id = id; | ||
} | ||
|
||
public String getMessage() { | ||
return message; | ||
} | ||
|
||
public void setMessage(String message) { | ||
this.message = message; | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
apollo-biz/src/main/java/com/ctrip/apollo/biz/message/DatabaseMessageSender.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 @@ | ||
package com.ctrip.apollo.biz.message; | ||
|
||
import com.ctrip.apollo.biz.entity.ReleaseMessage; | ||
import com.ctrip.apollo.biz.repository.ReleaseMessageRepository; | ||
import com.dianping.cat.Cat; | ||
import com.dianping.cat.message.Message; | ||
import com.dianping.cat.message.Transaction; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.util.Objects; | ||
|
||
/** | ||
* @author Jason Song(song_s@ctrip.com) | ||
*/ | ||
@Component | ||
public class DatabaseMessageSender implements MessageSender { | ||
private static final Logger logger = LoggerFactory.getLogger(DatabaseMessageSender.class); | ||
|
||
@Autowired | ||
private ReleaseMessageRepository releaseMessageRepository; | ||
|
||
@Override | ||
public void sendMessage(String message, String channel) { | ||
logger.info("Sending message {} to channel {}", message, channel); | ||
if (!Objects.equals(channel, Topics.APOLLO_RELEASE_TOPIC)) { | ||
logger.warn("Channel {} not supported by DatabaseMessageSender!"); | ||
return; | ||
} | ||
|
||
Cat.logEvent("Apollo.AdminService.ReleaseMessage", message); | ||
Transaction transaction = Cat.newTransaction("Apollo.AdminService", "sendMessage"); | ||
try { | ||
releaseMessageRepository.save(new ReleaseMessage(message)); | ||
transaction.setStatus(Message.SUCCESS); | ||
} catch (Throwable ex) { | ||
logger.error("Sending message to database failed", ex); | ||
transaction.setStatus(ex); | ||
} finally { | ||
transaction.complete(); | ||
} | ||
} | ||
} |
15 changes: 0 additions & 15 deletions
15
apollo-biz/src/main/java/com/ctrip/apollo/biz/message/DummyMessageSender.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.